0

My DAO gets information from the database using this line of code.

public Object[] getTagData() {
    List TagData = entityManager.createNativeQuery("SELECT sub.name, count(st.tags_tagId) as tagCount FROM subject as sub LEFT JOIN subject_tag  st on st.subject_subjectId = sub.subjectId GROUP BY sub.name;")
            .getResultList();

  return TagData.toArray();
}

It returns

[Ljava.lang.Object;@27d027d

I need to convert this into a String so that I know in what form it will return.

1 Answers1

0

As the result is not being stored in an Entity then it is being returned as an Object array, or rather an Object [][]

use a debugger and inspect the object you will see that TagData[0][0] contains the first column of the first row

Either you can create a specialized Entity for it and use it as per http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#createNativeQuery(java.lang.String, java.lang.Class)

or just iterate the two dim array

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64