0

Using an object that extends HibernateDaoSupport, I ran a query using this right here:

List<Object> trialList2 = getSession().createSQLQuery(trialQuery2).list();   

Where trialQuery2 is just some query that returned a single row. I got back a list with one Object on it, which when inspected in Eclipse looks like this:

[some, random, data]

I'd like to create an Object that can accommodate what I got back from the query, but a simple Javabean object that can has those fields doesn't seem to work. Does anyone know what kind of object I would have to make to be able to access those values?

2 Answers 2

2

It would be actually Object[] not Object

List<Object[]> trialList2

Based on columns in your select query, you get values from index

Let us say, if your query is select firstname, lastname from employee;

Object[0] would be firstname

Object[1] would be lastname.

As per documentation :

These will return a List of Object arrays (Object[]) with scalar values for each column in the table

Sign up to request clarification or add additional context in comments.

Comments

0

U can replace any class name for BEANCLASSNAME

List<BEANCLASSNAME> trialList2 = getSession().createSQLQuery(trialQuery2).setResultTransformer(new AliasToBeanResultTransformer(BEANCLASSNAME.class)).list();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.