Thoroughbred Object Cast

Source: Internet
Author: User

It's a very painful problem.

Scene, Hibernate reads data

@Override public  list<object> getranklist (date stime, date etime, int type, int num) {    String hql =        "sel ECT p.content, SUM (p.count) from Profilejudgecount P "            +" where P.type =: Type and p.date between:stime and:etime "            + "GROUP by p.content Order by sum (p.count) desc limit 0," + num;    Return Sessionfactory.getcurrentsession (). CreateQuery (HQL). Setinteger ("type", type).        setDate ("Stime", stime). SetDate ("ETime", etime). List ();  }

Returned is a list of obj ect, the phenomenon of debuggingin Eclipse Environment

Figure one: Directly view the returned List object L, shown below

Figure Two: Click on a specific element, shown below, to see what's inside, a string, a value,

Figure three: Trace view element specific content, is the number of groups, the first element is a string, the second element is a long integer

Positive three, ToString function, get [ljava.lang.object;@9654f70 similar content

Try to convert the elements, using the GetClass function to find that the type is Java.lang.Object, which can only be cast so that the contents are removed

1: Custom entity, entity attribute a string, a long integer, conversion exception

2: Found similar to a jsonarray, conversion exception

3: Convert string[], convert exception

4: Convert list, convert exception

5: Convert serializable, get byte array, turn to string, can see Chinese, but there is garbled

Final conversion object[], success, wish, exhausted

Thoroughbred Object Cast

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.