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