Because the hql statement needs to query a string-type prefix, the type returned after the hql statement is queried is list <string>. If you want to query two or more fields, the return type is list <object []>. Then, traverse the list set and convert the corresponding fields to the corresponding type.
Public list <string> findbyhql (string provincename, string regionname, string yys) throws baseexception {try {stringbuffer hql = new stringbuffer (); hql. append ("select ps. prefix from phonesegment PS where Ps. province. name = "+" '"+ provincename +"' "); If (stringutils. isnotblank (regionname) {hql. append ("and PS. region. name = "+" '"+ regionname +"' ");} If (stringutils. isnotblank (yys) {string [] STRs = yys. split (","); string phonetypes = ""; for (INT I = 0; I <STRs. length; I ++) {phonetypes + = enum. valueof (phonetype. class, STRs [I]). ordinal () + ",";} phonetypes = phonetypes. substring (0, phonetypes. length ()-1); hql. append ("and phonetype in (" + phonetypes + ")");} return basedao. find (hql. tostring ();} catch (exception e) {log. error (E. getmessage (), e); throw new baseexception (e );}}