Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-05-06
3
Medium Priority
?
11,143 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
[X]
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
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

604 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