Package org.hibernate

Examples of org.hibernate.Session$LockRequest


   * @param userid
   * @return
   * @throws IOException
   */
  public static int cleanupOfSession(String session_id, int userid) throws Exception{
    Session ssn = getSession();
    if(ssn == null)
      return -1;
    int er = 0;
    try{
      beginTransaction();
      List beans = findNamedAll("LIST_ORPHAN_FILES_IN_SESSION",
          new Object[] { new Integer(userid), session_id });
      for(int i=0;i<beans.size();i++){
        FckUploadFileBean fufb = (FckUploadFileBean)beans.get(i);
        FCK_UploadManager.getUploadHandler().remove(fufb);
        ssn.delete(fufb);
        er ++;
      }
      commit();     
    }catch(HibernateException e){
      rollback();
View Full Code Here


   */
  public Session getSession(){
    if(sessions == null)
      return null;

    Session ssn = (Session)sessions.get();
    if (ssn == null) {
      ssn = sessionFactory.openSession();
      sessions.set(ssn);
    }
   
View Full Code Here

   */
  public void closeSession(){
    if(sessions == null)
      return;
    // Would be written as a no-op in an EJB container with CMT
    Session ssn = (Session)sessions.get();
    if(ssn == null)
      return;
    else if(ssn.isOpen())
      ssn.close();   
   
    sessions.set(null);
  }
View Full Code Here

    if(transactions == null)
      return;
    // Would be written as a no-op in an EJB container with CMT
    Transaction tx = (Transaction)transactions.get();
    if (tx == null || tx.wasCommitted() || tx.wasRolledBack()) {
      Session ssn = (Session)sessions.get();
      if(ssn == null){
        ssn = getSession();
        tx = ssn.beginTransaction();
        transactions.set(tx);
      }
      else if(ssn != null){
        tx = ssn.beginTransaction();
        transactions.set(tx);       
      }
    }
    else{
      if(tx!=null && log.isWarnEnabled())
View Full Code Here

      msg.setContent(content);
      msg.setSendTime(new Date());
      msg.setFromUser(sender);
      msg.setStatus(MessageBean.STATUS_NEW);
      //����д�����ݿ�
      Session ssn = getSession();
      beginTransaction();
      for(int i=0;i<users.size();i++){
        UserBean user = (UserBean)users.get(i);
        msg.setToUser(user);
        ssn.save(msg);
        if(i % 20 == 0){
          ssn.flush();
          ssn.clear();
        }
      }
      commit();
    }catch(HibernateException e){
      rollback();
View Full Code Here

   * @param old_msg_id
   * @param msg
   */
  public static void replyAndDeleteMessage(int old_msg_id, MessageBean msg){
    try{
      Session ssn = getSession();
      beginTransaction();
      //�ظ�����Ϣ
      ssn.save(msg);
      //ɾ�����ظ��Ķ���Ϣ
      if(old_msg_id > 0)
        executeNamedUpdate("DELETE_MESSAGE", old_msg_id, msg.getFromUser().getId());
      commit();
    }catch(HibernateException e){
View Full Code Here

    StringBuffer hql = new StringBuffer("DELETE FROM MessageBean AS f WHERE f.toUser.id=? AND f.id IN (");
    for(int i=0;i<max_msg_count;i++){
      hql.append("?,");
    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<max_msg_count;i++){
        String s_id = (String)msgIds[i];
        int id = -1;
View Full Code Here

    StringBuffer hql = new StringBuffer("DELETE FROM FriendBean f WHERE f.owner=? AND f.friend.id IN (");
    for(int i=0;i<friendIds.length;i++){
      hql.append("?,");
    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<friendIds.length;i++){
        String s_id = (String)friendIds[i];
        int id = -1;
View Full Code Here

    StringBuffer hql = new StringBuffer("DELETE FROM MyBlackListBean f WHERE f.myId=? AND f.other.id IN (");
    for(int i=0;i<otherIds.length;i++){
      hql.append("?,");
    }
    hql.append("?)");
    Session ssn = getSession();
    try{
      beginTransaction();
      Query q = ssn.createQuery(hql.toString());
      q.setInteger(0, ownerId);
      int i=0;
      for(;i<otherIds.length;i++){
        String s_id = (String)otherIds[i];
        int id = -1;
View Full Code Here

   * @param lastLogin ���һ�ε�¼��ʱ��
   * @param manual_logout �Ƿ��ֹ�ע��
   * @return
   */
  public static int userLogout(int userid, Timestamp lastLogin, boolean manual_logout){
    Session ssn = getSession();
    if(ssn == null)
      return -1;
    try{
      beginTransaction();
      Query q = ssn.getNamedQuery(manual_logout?"USER_LOGOUT_1":"USER_LOGOUT_2");
      q.setInteger("online_status", UserBean.STATUS_OFFLINE);
      if(manual_logout)
        q.setInteger("keep_day", 0);
      q.setInteger("user_id", userid);
      q.setTimestamp("last_time", lastLogin);
View Full Code Here

TOP

Related Classes of org.hibernate.Session$LockRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.