-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: flush_before_completion to true in hibernate-service.xml
PostPosted: Tue May 24, 2005 11:16 am 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
How to set flush_before_completion and auto_close_session to true in hibernate-service.xml. I do not know the attribute names. Could some please tell me what they might be


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 25, 2005 12:32 pm 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
I have to do the following in bold in my class to ensure that the flush happens. If I do not than I can not update ro delete. The explicit calls to s.setFlushMode(FlushMode.AUTO) and s.flush() needs to be made to ensure that updates and deletes can occur. I want to make sure is this right?

Code:
public static final ThreadLocal session = new ThreadLocal();
       
    public static Session currentSession()
            throws  HibernateException {

          Session s = (Session) session.get();
          if (s == null) {
             try {
                 SessionFactory sf = (SessionFactory) new InitialContext().lookup("java:hibernate/HibernateFactory");
                 s = sf.openSession();
                 [b]s.setFlushMode(FlushMode.AUTO);[/b]
                 session.set(s);
             }
             catch (Exception e) {
                  e.printStackTrace();
             }
          }
         
          return s;
        }

        public static void closeSession() throws HibernateException {
           Session s = (Session) session.get();
           [b]s.flush();[/b]
           session.set(null);
           if (s != null) s.close();
        }


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.