Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to extract values from entityManager.createNativeQuery(query).getResultList();

Posted on 2009-05-06
3
11,009 Views
Last Modified: 2012-05-06
Hello,

I execute a SQL statement, but the values of the resulset are diferents. I set the ArrayList as String and I try to extraact the resultset but I just get the Object for example Ljava.lang.Object;@1d31f85.

I read like this:
ArrayList<?> List = entity.Queries(DataSource, query);
                for (int i = 0; i <List.size(); i++) {

                    System.out.println("Resultset" +List.get(i));
              }

How can I extract the values?

Thank you!
public ArrayList<String> Queries(final String DataSource, final String query) {
        EntityManager entityManager = getEntityManagerDataSource(DataSource);
        return (ArrayList<String>) entityManager.createNativeQuery(query).getResultList();
 
    }
 
entityManager.createNativeQuery(query).getResultList();

Open in new window

0
Comment
Question by:Fionageo80
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 24314129
>>System.out.println("Resultset" +List.get(i));

Try
>>System.out.println("Resultset" + java.util.Arrays.toString((Object[])List.get(i)));

Open in new window

0
 

Author Comment

by:Fionageo80
ID: 24314409
Thanks a lot!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24314433
:-)
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
factorial example 4 47
hibernate example using maven 12 56
jsp insert to database example 2 43
ejb message driven bean mdb creation steps 2 15
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question