A json object is required in the project, and the column name of the data is required during encapsulation. In jdbc, you can have a ResultMetaData object to get the column name. Because I use hibernate, this framework has already encapsulated a lot, and it is generally difficult to obtain the resultset. After unremitting bing and google (as an environmentally friendly quasi-programmer, Baidu is rejected), we found that in hibernate, we can obtain the resultset object. However, it is now hibernate4, which is relatively new, and the acquisition method has changed a lot. In the previous hibernate, you can use the following code to obtain the connection and other objects. Copy the java code. SQL. connection c = null; java. SQL. preparedStatement ps = null; java. SQL. resultSet rs = null; public List method (String SQL) {List ret = new ArrayList (); try {c = SessionFactoryUtils. getDataSource (getSessionFactory ()). getConnection (); ps = c. prepareStatement (SQL); rs = ps.exe cuteQuery (); while (rs. next ()){.....} ret. add (ro) ;}} catch (Exception e) {e. printStackTrace ();} finally {cl Ose ();} return ret;} copies the code so that objects such as resultset can be used like jdbc. However, in hibernate4, the method has been changed. The SessionFactoryUtils. getDataSource (getSessionFactory (). getConnection () Statement is no longer available, but the new method is used. GetSession (). doWork (new Work () {@ Override public void execute (Connection connection) {}}); you can directly use connection in the method body. In this case, a void is returned, and what I want to use is to obtain the resultset object. Fortunately, IDE has a smart prompt and finds that there is a method that can pass the returned value, which is an extension of the above method. Directly copy the code in my project: copy the code @ Test public void tests () throws SQLException {Session session Session = HibernateSessionFactory. getSession (); ResultSet resultSet = session. doReturningWork (new ReturningWork <ResultSet> () {@ Override public ResultSet execute (Connection connection) throws SQLException {String SQL = "select * from t_auth"; PreparedStatement preparedStatement = connection. prepareStatement (SQL); ResultSet resultSe Tsung preparedstatement.exe cuteQuery (); return resultSet ;}}); while (resultSet. next () {System. out. println ("rs:" + resultSet. getString ("authid");} the copy code is the doReturnWork method, which uses an internal class to return the resultset object to the doReturnWork layer by layer, in this way, you can use hibernate like jdbc. I have some personal experiences and hope to help you.