0
votes

Here is what I am trying to do: 1. Send an HQL to populate "User" Hibernate object. 2. Send a native SQL to retrieve a smaller dataset from a very large data column from "User" table. 3. Combine the mapped Hibernate object with the column result from step 2.

I read that ResultTransformer can be used to map the resultset from 2 to a Hibernate entity, which in my case the "User" entity. Is there a way to insert the results of the ResultTransformer mapping to my original User entity?

Here's some example: 1. HQL - From User. We use Hibernate mapping file for User and using Bytecode Enhancement, we set "xmlStringColumn lazy=true". String hql = "FROM User"; List users = session.createQuery(hql).list(); 2. we send a query
List resultXML = s.createSQLQuery( "XML SQL to get specific data") .setResultTransformer( Transformers.aliasToBean(User.class)) .list();

User dto =(User) resultWithAliasedBean.get(0); //Will need code to combine the User dto from the SQL to the original

1

1 Answers

0
votes

ResultTransformer bundles one to many relationship objects into single object. For example,

Class A{

Set b=new Hashset();

}

So if you start query from class A and add join on B it will end up in creating multipe objects of A.

ResultTransformer bundles data into single A object.

Can you please post code so we can understand what you are tyring to acheive!!!