Hibernate3.3 note, hibernate3.3 note

Source: Internet
Author: User

Hibernate3.3 note, hibernate3.3 note

// ---------------- Transaction (modify, delete, and save) Session s = getSession (); Transaction t = s. beginTransaction (); getSession (). delete (persistentInstance); t. commit (); // query statement public List <Cls> I = new ArrayList <Cls> (); public String execute () {ClsDAO clsDAO = new ClsDAO (); I = clsDAO. findAll (); return "1";} // Delete statement
StuDAO In = new StuDAO (); I = In. findstuid (stu_id); In. delete (I. get (0); // Add the statement public String stu_name; public Integer stu_age; public Integer cls_id; public String execute () {ClsDAO clsDAO = new ClsDAO (); cls cls = clsDAO. findById (cls_id); StuDAO stuDAO = new StuDAO (); Stu stu = new Stu (cls, stu_name, stu_age); stuDAO. save (stu); return "1" ;}// modify the statement public String stu_name; public Integer stu_age; public Integer cls_id; public Integer stu_id; public String execute () {ClsDAO clsDAO = new ClsDAO (); Cls cls = clsDAO. findById (cls_id); Stu stu = new Stu (cls, stu_name, stu_age, stu_id); // you can write your own constructor StuDAO studentsDAO = new StuDAO () with the primary key ID (); studentsDAO. merge (stu); return "1" ;}// the student table in DAO queries the public List findClsid (Integer cls_id) according to the class ID) {String queryString = "from Stu where cls_id = '" + cls_id + "'"; Query queryObject = getSession (). createQuery (queryString); return queryObject. list ();} // JS-based pseudo-webpage direct access to action, used without triggering, <script type = "text/javascript"> window. location. href = "all. action "; </script>

// S tag, traverse the List array, and generate tables and other data tables <% @ taglib prefix = "s" uri = "/struts-tags" %> <s: iterator value = "I"> <s: property value = "stuId"/> </s: iterator>

  

//struts2 <constant name="struts.i18n.encoding" value="utf-8" /><package name="denglu" extends=" struts-default"><action name="all" class="com.all"><result name="1">/all.jsp</result></action>          <action name="up_save" class="com.up_save"><result name="1" type="redirectAction">all</result></action></package>

  

Tag a returns to the previous step.
<A href = "javascript: history. go (-1)"> return </a>

JS form cannot be empty for Detection

<Script type = "text/javascript"> function myCheck () {for (var I = 0; I <document. form1.elements. length-1; I ++) {if (document. form1.elements [I]. value = "") {document. getElementById ("showResult "). innerHTML = "Enter the complete student information! "; Document. form1.elements [I]. focus (); return false ;}} return true ;}</script> <form name = "form1" action = "add. action "method =" post "onSubmit =" return myCheck () "> </form> <span id =" showResult "style =" color: red; "> </span>

  

  

  

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.