79 questions
0
votes
2
answers
546
views
@NamedNativeQuery and @SqlResultSetMapping: No converter found capable of converting from type [$TupleConverter$TupleBackedMap]
I am getting the following stacktrace:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query....
1
vote
1
answer
2k
views
Unknown SqlResultSetMapping
I've been sitting here for long to solve this problem.
(I can't show a lot of code because it is corporate secret so here will be parts of it or just examples)
I have my project connected to 2 ...
0
votes
1
answer
948
views
How to Dynamically Retrieve JDBC ResultSet Data
The requirement is :-
The application will run dynamic SQLs and show the results in table format in JSP. The SQL passed to the application will change, which means the number, name, datatype of ...
1
vote
0
answers
1k
views
how to bind result of native query in data jpa to an entity with a @transient field
I work on a spring boot, data jpa web application and have a problem with an entity that has a @transient field and I want to bind result of my native query to this entity (all fields even @transient ...
0
votes
0
answers
264
views
Spring Data JPA NamedNativeQuery with SqlResultSetMapping and externalized query
I have a situation where I am making a read request to a database with a long, complex query that needs to map to a complex object. Based on my research, it looks like I want to use @...
0
votes
2
answers
941
views
Hibernate is not initialising nested entities when using NamedNativeQuery
The challenge:
I am trying to batch fetch a collection of nested entities from my database. The resulting dataset ranges in the thousands of entities so my approach is to fetch entities in a paged ...
0
votes
0
answers
257
views
JDBC ResultSet - Many To Many
Greeting to all,
As I'm learning Java, JDBC and MySQL
I reach one point where I would like to perform the following
I have 2 entites
class User {
private Long id;
private String username;
...
...
...
1
vote
1
answer
1k
views
Doctrine ResultSetMapping(Builder) is not showing any results
My normal query was looking like this.
$qb = $placeRepository->createQueryBuilder('p');
var_dump($qb->getQuery()->getResult());
I'll get few results as objects.
So this is the normal ...
0
votes
1
answer
371
views
@SqlResultSetMapping binding inner class to targetclass
In my project, I have created a view that contains multiple joins. The following is part of the query from the view.
a.id,
b.object1,
b.object2,
b.object3,
case when (c.type = 'qrt' then c.object4 ...
0
votes
0
answers
2k
views
Calling Stored Procedure and mapping the query result to non-entity POJO using Spring JPA SqlResultSetMapping
I am attempting to map the results of a Stored procedure to a non-entity POJO using @SqlResultSetMapping with @ConstructorResult. Here is my code:
@MappedSuperclass
@SqlResultSetMapping(name = "...
0
votes
0
answers
150
views
java jpa SqlResultSetMapping issue
I have a table form_header with 3 records
There are more fields in the table decided not to add it here in the post since most are irrelevant. I created a class/entity to get the count with distinct ...
0
votes
1
answer
365
views
How to get only the value from the SQL query output without parentheses
Here is my code in the flask app
from flask import Flask, render_template
from flask_mysqldb import MySQL
import MySQLdb.cursors
app = Flask(__name__)
app.config['MYSQL_HOST'] = 'localhost'
app....
-1
votes
1
answer
545
views
How to get total qty and consumed qty into single results using SQL query
I am having below Tables
1. Material Unit:
id | Unit_name
1 | Nos.
2 | lts
2. Material Table:
id | Material_name
1 | bricks
2 | Cement
3. Grn Table:
id | material_id | qty | unit
1 | 1 ...
0
votes
1
answer
989
views
SQL Server update statement based on Select Statement with multiple values
I have a Select Statement which works well, producing 7636 rows:
SELECT c.ClientId
FROM dbo.tblTreatment e
JOIN dbo.tblProgramAssessment pa
ON pa.TreatmentID = e.TreatmentId
...
0
votes
1
answer
2k
views
Can @SqlResultSetMapping be used to map a complex Dto object
I currently have a named native query set up in CrudRepository where I'm joinnig few tables and I need to map that query result into a Dto.
select
event_id, replaced_by_match_id, scheduled, ...
0
votes
0
answers
2k
views
SqlResultSetMapping Unknown mapping error
I am working on a Spring boot rest API and i asked a question earlier about mapping pojo class to result set
Could not locate appropriate constructor on class.....
the answers I got worked ...
1
vote
0
answers
278
views
Mapping different native queries result to same POJO with same SqlResultSetMapping?
I need to execute several different queries and I want to use the same POJO to get the results. What I get with those queries are combinations of same columns, can I reuse the same sqlResultSetMapping?...
6
votes
1
answer
13k
views
JPA mapping native query result to non entity DTO
I have a complex native query and I am trying to map its result to a non-entity DTO class. I am trying to use JPA's SqlResultSetMapping with ConstructorResult
My DTO class
@Data
public class Dto {
...
0
votes
0
answers
656
views
@ColumnResult maps to Character instead of String in JPA 2.0
In our software, we had a requirement that display name of one UI will be configurable according to user. So one user want to display another column from one table and another user want to display ...
0
votes
0
answers
98
views
SQL query isn't working when embedded in java
I'm trying to connect the SQL plus database with java but it's not working , I'm using netbeabs ide 8.0.2
Here i have pasted following cod
e in my submit button but when I execute it then it goes ...
0
votes
0
answers
525
views
Mapping complex native query to a complex non-entity object in JPA/Hibernate
In mybatis we can define very complex mapping of the sql result set to an arbitrary complex dto object. Take a look at the example here:
http://www.mybatis.org/mybatis-3/sqlmap-xml.html
at the ...
0
votes
1
answer
829
views
Map result set to custom pojo which is not entity
I need to fetch 4 columns by joining multiple tables. I have created the query. But how can I map the result set to a pojo which is not an entity and i want to use Spring Data JPA.
Could someone ...
0
votes
1
answer
2k
views
hibernate native query complex constructor mapping
Java, Spring Data JPA
I have 2 entities:
class Source {
Integer id;
String name;
}
class Item {
Integer id;
String name;
Integer sourceId;
}
I need statistic native query result like ...
1
vote
1
answer
2k
views
Mapping an SQL native query to a POJO class
I tried to map a native SQL query to a POJO class using @ConstructorResult of @SqlResultSetMapping as following :
@SqlResultSetMapping(
name = "AnomalieMapping",
classes = @...
14
votes
1
answer
20k
views
@NamedNativeQuery with @SqlResultSetMapping for non-entity
I have been using this post as an example.
I have a complex join query (simplified here). It returns a subset of values from two tables (and a derived column using CASE). I don't think I need to use ...
0
votes
1
answer
530
views
JPA SqlResultSetMapping object order
JPA: if classes, entities and columns are defined in @SqlResultSetMapping, what is the order of objects returned?
@SqlResultSetMapping(
name="CustomerDetailsResult",
classes={
...
1
vote
0
answers
691
views
JPA SQLResultSetMapping for SQL Aliases not Working At All?
Native SQL with aliased field names + remapping to receive managed entities is required for more complex queries with joined tables.
However, the mapping of the SQL aliases leads to an exception ...
9
votes
1
answer
3k
views
How to map ONE-TO-MANY native query result into a POJO class using @SqlResultSetMapping
Im working in a backend API using Java and MySql, and I'm trying to use @SqlResultSetMapping in JPA 2.1 for mapping a ONE-TO-MANY native query result into a POJO class, this is the native query:
@...
0
votes
0
answers
305
views
Spring's ResultsSetExtractor for SQL inner join statement
I'm trying to use ResultSetExtractor to send a SQL statement to the database, but the method is getting stuck at the line l.setId(resultSet.getInt("Id"));.
This is my error message:
"message": "...
22
votes
4
answers
30k
views
JPA Data Repositories with SqlResultSetMapping and native queries
I was stuck with the following situation:
My entities are related to each other, but in such a way that i could not use JPQL. I was forced to use native SQL. Now I want to map these results to a ...
3
votes
2
answers
2k
views
Trying to put the Result set Values inside a Map
I'm trying to put the Result Set (DB Query Values) inside a LinkedHashMap>.
Every Iteration of row. The value is getting overriden while putting into DBMap.
<LinkedHashMap<String, String>&...
1
vote
3
answers
1k
views
SQL Query Buffer in result - Show one by one
I have a sql script as follow :
declare db_list cursor for
select name From sys.databases
open db_list
declare @var varchar(MAX)
fetch next from db_list into @var
print @var
while (@@FETCH_STATUS =...
0
votes
0
answers
518
views
Why cannot I use @SqlResultSetMapping with query cursor hint
In Eclipselink, when I use @SqlResultSetMappings and I use Query Hint eclipselink.cursor, the console shows me the following exception:
Caused By: java.lang.IllegalArgumentException: Query null, ...
1
vote
1
answer
514
views
Join two entities in a non entity class
I want to join two entities in a non-entity class, which will have the two entities as attributes of the class.
Take this as example:
@Entity
public class A {
}
@Entity
public class B {
}
public ...
0
votes
1
answer
891
views
class cast exception using SqlResultSetMapping and ConstructorResult
I'm trying to map the results of a NativeQuery to a non-entity pojo, using SqlResultSetMapping and ConstructorResult
I'm using this StreetCity class, with result mapping:
@Data
@SqlResultSetMapping(...
0
votes
1
answer
4k
views
Different result for @SQLResultSetMapping+Joins on multiple entities | JPA
I am running a NativeQuery with JPA that gives different results compared to running the query in an sql tool. Probably I missunderstand s.th. within the concept of @SQLResultSetMapping.
--- Overview ...
0
votes
1
answer
688
views
How to use @SqlResultSetMapping in Symfony2, doctrine 2?
There is an example about @SqlResultSetMapping in
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/native-sql.html
I do not understand where and how i should use it? In ...
1
vote
1
answer
6k
views
@SqlResultSetMapping @ConstructorResult @ColumnResult doesn't work for java.time.LocalDate
I have a simple entity
@Entity
@NamedNativeQueries({
@NamedNativeQuery(name = "Account.dailyRegistered",
query = "select date(date_trunc('day', creation_date)) as period, count(1) as ...
0
votes
1
answer
404
views
SQL postgres - How to rename each column after join because their are too many fields
I want to join two tables and read all the columns within java. In java the resultset contains all the fields but they have the same names for both tables.
Their are about 65 columns and I do not want ...
1
vote
1
answer
2k
views
Call stored procedure using JPA 2.1 and do Sql Result SetMapping to Pojo
I am trying to call a stored procedure which returns a non entity object using JPA. Here is what I do.
StoredProcedureQuery query = entityManager.createStoredProcedureQuery(
"DepAndTerm", ...
2
votes
3
answers
4k
views
Java JPA Hibernate SqlResultSetMapping Aliases
In Java application which uses JPA 2.1 with Hibernate 4.3.11 implementation I am trying to use SqlResultSetMapping to map native query results to entity. Query includes joined two tables with same ...
3
votes
2
answers
3k
views
JPA Native Query Result Set Mapping with repeating data and a list
I'd like to map data from a native query to an object with a list in it.
Let's say I have this query (it's a contrived example of what I want to do)
select p.id, p.name, a.address, a.city, s....
2
votes
1
answer
595
views
Open JPA ResultSet mapping
I have an entity called order which contains 10 columns and also has embedded id(composite key) columns which contains 5 fields in entity order.
Here is my sql query
<named-native-query name="...
1
vote
1
answer
930
views
Symfony2 Error: Object of class Doctrine\ORM\EntityManager could not be converted to string
I have 2 non related entities: External and Internal. I need to union select all results from entities. I am using ResultSetMapping and Native SQL to do this:
$em = $this->getDoctrine()
-&...
0
votes
1
answer
166
views
Creating JSON properly from SQL Resultset using Java
I have a table as
Country State
USA Texas
USA Alasca
India Delhi
India Bombay
India Madras
Russia Mosco
Russia Petersberg
...
0
votes
1
answer
45
views
get sums for pivot results
@DateMonth as INT,
@DateYear as INT
AS
--set @DateMonth = 08
--SET @DateYear = 2015
DECLARE @FromDate DateTime;
DECLARE @ToDate DateTime;
SET @FromDate = CONVERT(DateTime, ...
1
vote
1
answer
4k
views
How to Map Result Set of Native Query to Variable in Entity
I have two entities, Users and Annotations, and I want to add a set of results from a query on the Annotations table to a transient variable in the Users entity.
Entities:
Users
@Entity
...
0
votes
0
answers
150
views
jpa native query control entity(part 2)
Cont. on jpa native query retrieve multiple entities
My database (testing)
company - ID {PK}, name
staff - ID{PK}, name, companyID{FK}
department - ID{PK}, name, companyID{FK}, staffID{FK}
project - ...
0
votes
1
answer
2k
views
symfony2 / doctrine: how to use ResultSetMapping with count
I have an archive table (id, title, author) and a download_history table (id, id_archive, date) to keep track of how many download for each archive. Now I want to build a report to view the most ...
3
votes
1
answer
4k
views
jpa native query retrieve multiple entities
I have a database with 4 tables:
company,staff,department,project
Company.java
@Entity
@Table(name = "company")
@SqlResultSetMapping(name = "COMPANY", entities =
{
@EntityResult(entityClass = ...