Session session = currentSession();
        Transaction t = session.beginTransaction();
        
        TUser user =new TUser();
        user.setUsername(registerForm.getUserName);
        session.save(user);
        TUserinfo userInfo =new TUserinfo();
        userInfo .setName(registerForm.getUserName);
        session.save(userInfo);
        session.flush();        
        t.commit();        
        closeSession();

解决方案 »

  1.   

    <table width=100% border=1 align="center" cellPadding=0  cellSpacing=0 borderColorDark=#E8E8E8 borderColorLight=#999999 >
              <tr> 
                <td>A:</td>
                <td><html:text property="A" size="12"/></td>
                <td>B:</td>
                <td><html:text property="B" size="10"/></td>
              </tr>
              <tr> 
                <td colspan="4"> <input type="checkbox" name="v_checkbox" value="checkboxA"  onClick="if(this.checked==true){wxp.style.display='';wxx.style.display='';}else {wxp.style.display='none';wxx.style.display='none';}">D
                </td>
              </tr>
              <tr id="wxp" style="display:none"> 
                <td>a:</td>
                <td><input name="a" size="10"type="text" id="a" > 
                </td>
                <td>b;</td>
                <td><input name="b"  size="10"type="text" id="b" ></td>
              </tr>
              <tr> 
                <td colspan="4"><div align="center">
                  <input type="submit" name="Submit" value="确定">
                <input type="reset" name="reset" value="取消" onClick="operate(0, 64)"
             
                  </div></td>
              </tr>
            </table>按确定按钮时,把A和B中的数据写入到一张表,把a和b的数据写入到另外一张表中,
    怎么样在这个程序里改?
      

  2.   

    晕的很,你为什么,非得要用A,B与a,b??在form中的getXX()方法中,第一个字母是大写的。
    那你现在A,B与a,b,而getA(),getB取得是a?A b?B.最好把A,B换个名字。在form另定义个。这样分开插入就没问题。
      

  3.   

    A,B和a,b我只是随便写的,名字都可以换的,而property中的值和实体类中是变量名是相同的,
    具体怎么弄我还是不清楚.
      

  4.   

    前台不用管数据是怎样插入到数据库里的。
    后台的功能就是要区分abAB,然后去执行相应的session.save(object),可以了。但要注意一点,是要在同一事务下。