Heibernate additions and deletions to summarize their shortcomings

Source: Internet
Author: User

  I am not familiar with the difficulty is the writing of database statements, to strengthen the writing of complex query statements

1 /*It's easy to use in a shared class.2 * Summary:3      * 4 *--------------------------------------Enquiry5 * 1.HQL Query6      * 7 * StringBuffer hql = new StringBuffer ("from station where 1=1");8      *  9 * Query q = GS (). CreateQuery (Hql.tostring ());Ten      *   One * Q.list (); A      *  - * 2.sql Query -      *  the * String sql = "Select CZMC,CZDM from Station where DJ like '%" + DJ - + "% '"; -                  - sqlquery q = GS (). createsqlquery (SQL); SQL query using Createsqlquery +          - q.list ();  +      *  A * Datazh.objarrtostrarr (Q.list ())//sql query returns an object, remember to convert at      *  -      *  - *--------------------------------------additions and deletions - * Execute using native SQL statements -      *  - * String sql = "Delete from station where czdm=" + ID; in      *  - * Transaction tx = NULL; to tx = GS (). BeginTransaction (); +  - sqlquery q = GS (). createsqlquery (SQL); the          *          $ * TX.COMMIT ();//Submit TransactionPanax Notoginseng      *  - * Q.executeupdate ()//Adding or deleting statements using this function the      *  + * return result//returns the number of rows affected A      *  the      */

Heibernate additions and deletions to summarize their shortcomings

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.