Questions tagged [resulttransformer]
24 questions
38
votes
1 answer
getting result set into DTO with native SQL Query in Hibernate
I have a query like below
select f.id, s.name, ss.name
from first f
left join second s on f.id = s.id
left join second ss on f.sId = ss.id
If I could use HQL, I would have used HQL constructor syntax to directly populate DTO with the result…

Reddy
- 8,737
- 11
- 55
- 73
7
votes
1 answer
How do we modify HQL transformer while loading a specific parent or another mapped entity property?
This is an important addition especially to solve performance issues while being able to write efficient dynamic HQL queries.
But, how do we modify the HQL transformer in case of loading a specific parent or another mapped entity property?
The…
None
7
votes
1 answer
Projections in NHibernate
suppose in an entity there are attributes id, username, age, address. Now I just want id and username and I use this code for it.
Projections enable the returning of something other than a list of entities from a query.
var proj =…

Rishabh Ohri
- 1,280
- 4
- 16
- 28
6
votes
0 answers
Using Entity Graph with DTO Projection using ResultTransformer returns null value
Hello I am new in jpa + criteria API + hibernate..
I have doubt related to use of ResultTransformer in jpa criteria API.
I am having two entity Department and Employee. one to many mapping between department and employee. i want to use entitygraph…

Bharti Ladumor
- 1,624
- 1
- 10
- 17
5
votes
1 answer
NHibernate Future Query with ResultSetTransformer
i'm trying to query arbitrary sql data with nhibernate, it works fine as long as i don't use the Futures feature, however, when I use Futures, the data doesn't get passed into the ResultSetTransformer.
Example Code:
public class…

Bryan Pedlar
- 138
- 1
- 7
3
votes
1 answer
ResultTransformer in Hibernate return null
I'm using ResultTransformer to select only particular properties from entity, just i don't need all properties from entity.
But the problem i faced is when a property is "one-to-many".
Here is a simple example.
@Entity
@Table(name =…

brakebg
- 414
- 3
- 11
- 24
3
votes
2 answers
Java Hibernate @OneToMany Criteria Projections returning NULL
I have One to many relationship Owner->Dog.
I am to query the dog by ID as well bring the Owner in EAGER way I have set this code using Hibernate 4.1.6 not XML mapping is used. i only need some fields from DOG and OWNER using Projections
the SQL…

chiperortiz
- 4,751
- 9
- 45
- 79
2
votes
2 answers
Nhibernate 2nd level Cache with AliasesToBean transformer
I have an entity:
public class SalesUnit
{
public virtual long Id { get; set; }
public virtual string Name { get; set; }
}
And related Dto:
public class SalesUnitDto
{
public long Id { get; set; }
public string Name { get; set;…

Roman Koliada
- 4,286
- 2
- 30
- 59
2
votes
2 answers
NHibernate AliasToBean transformer throws then the QueryOver alias is a private field
I'm using the NHibernate 3.3.1.4000 from NuGet in .net 4.5 targeted project in VS2015.
I have two environments, first env1 a windows 8.1 with VS2012 and VS2015,
and second one env2 with windows 10 and only VS2015.
As is stated in QueryOver docs,…

Moga Ion
- 51
- 5
1
vote
0 answers
How to get Hibernate ResultTransformer to work with entity that have relations with other entities
i have Employee , Role , Department domains
Employee , Role have many to many relationship.
Employee , Department have many to one relationship.
@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "fk_department_id")
private…

fresh_dev
- 6,694
- 23
- 67
- 95
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
1
vote
1 answer
Hibernate native SQL query - how to get distinct root entities with eagerly initialized one-to-many association
I have two entities Dept and Emp (real case changed and minimized). There is 1:n association between them, i.e. properties Dept.empList and Emp.dept exist with respective annotations. I want to get List whose elements are distinct and have…

Tomáš Záluský
- 10,735
- 2
- 36
- 64
1
vote
1 answer
How to map TypedQuery result to custom object list
I need to make some select and map it to custom DTO
public class SomeClass {
@PersistenceContext
private EntityManager em;
public void doSomething() {
CriteriaBuilder builder = em.getCriteriaBuilder();
…

JVic
- 161
- 1
- 12
1
vote
1 answer
nHibernate criteria ResultTransformer not working
I have (long and complcated) query, based on Criteria.
The following code:
//....
var myList = criteria.List()
works fine, but it returns list of 50 whole entities. For performance reasons, i want to apply projection for my query. The…

Jakub Szułakiewicz
- 821
- 5
- 22
1
vote
0 answers
Can Hibernate's result transformer be used to map to related non-managed entities?
I have used ResultTransformer to map to simple non-managed entities, i.e that doesn't have relation to other entities. But I was wondering if it is possible through hibernate to map to a set of related non-managed entities? Just to make it clear, if…

opensourcegeek
- 5,552
- 7
- 43
- 64