Home > Software engineering >  Get SQL Result as list of String
Get SQL Result as list of String

Time:12-23

From Java I make this query to SQL:

protected EntityManager em;
Query query = em.createNativeQuery("select * from table2");

Now I need to save this query as List of String or Object (so without a POJO), but evrytime I get the andress of memory:

[[Ljava.lang.Object;@1d905cdf, [Ljava.lang.Object;@5e53d7b5, [Ljava.lang.Object;@1d2f8f05]

Does anybody knows how can I fix this?

CodePudding user response:

Try this :
TypedQuery<table2> query = em.createQuery("select * from table2", table2.class); then get resultList : List<table2> myList = query.getResultList(); This will return a list of table2 object.

  • Related