Solved

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

Posted on 2009-05-06
3
10,956 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
Comment Utility
>>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
Comment Utility
Thanks a lot!
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:-)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now