-->
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.  [ 5 posts ] 
Author Message
 Post subject: Help in find()/get()...
PostPosted: Fri Jul 16, 2004 5:54 am 
Newbie

Joined: Fri Jul 16, 2004 5:50 am
Posts: 3
Location: Chennai, India
Hai
I have a small probs with the find()/get(). Am using either of these method to fetch all the records from the database. But my problem is that when i try to add a new record manually in the backend then these methods are not getting the exact record which i add in the back end. what might be the problem. But the an updated records are shown when i do a add or delete from the UI. Am using MySQL as my backend.

Please help me to identify a solution for this

thanks in advance.
Senthil Kumar M Rangaswamy


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 16, 2004 6:03 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
show java code, you may have to manually flush() after adding a row

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 16, 2004 6:11 am 
Newbie

Joined: Fri Jul 16, 2004 5:50 am
Posts: 3
Location: Chennai, India
hai
thanks, am i have flush() after ever update/add/delete operation is that not the correct way.
Code:
/**
    * Get the list of all BSIF Adapter details.
    * @return the list of all BSIF Adapter details
    * @throws ObjectLoadException if there was a problem persisting the data
    * @throws TWCSQLException If there was a problem closing the JDBC connection
    */
   public List getAllBSIFAdapter() throws ObjectLoadException,
                                   TWCSQLException
   {
      log.trace("Entry to : getAllBSIFAdapter method.");
      log.info("Getting all BSIF Adapter Configuration.");
      // Create the Session
      log.debug("Open Hibernate Session.");
      Session hibernateSession = hibernateSessionHelper.openSession();
      List globalConfig = null;

      try
      {
         try
         {
            // Get all the BSIF Adapter details
            log.debug("Quering the Database.");
            globalConfig = hibernateSession.createQuery("select globalConfig from GlobalConfigDTO globalConfig").list();
         }
         finally
         {
            // Close the Session and the JDBC Connection.
            // hibernate. Release the connection mannually using the
            // releaseConnection of the Hibernate Helper Class
            log.debug("Close the JDBC Databse Connection.");
            hibernateSessionHelper.releaseConnection(hibernateSession.close());
         }
      }
      catch (HibernateException e)
      {
         throw new ObjectLoadException ("Could not get All the Global BSIF configuration details " + "(Caused by:" + e.getMessage() + ")");
      }
      catch (SQLException e)
      {
         throw new TWCSQLException("Error closing the JDBC connection while getting the list of BSIF adapters:" + "(Caused by:" + e.getMessage() + ")");
      }
      log.trace("Exit from : getAllBSIFAdapter method.");
      return globalConfig;
   }


Then above is the code to get all the records.

Code:
public long addBSIFAdapter(String jmsRequestQueue,
                              String jmsResponseTopic,
                              String jmsNotificationRequestTopic,
                              String jmsNotificationResponseQueue,
                              int jmsMessageTimeout,
                              int processingTimeOut,
                              int threadReconnectTime,
                              int maintenanceWindowStartTime,
                              int maintenanceWindowEndTime,
                              String maintenanceWindowTimezone)
                              throws ObjectCreationException, TWCSQLException
   {
      log.trace("Entry to : addBSIFAdapter method with parameter(s) " + jmsRequestQueue + "," + jmsResponseTopic + "," + jmsNotificationRequestTopic + "," + jmsNotificationResponseQueue + "," + jmsMessageTimeout + "," + processingTimeOut + "," + threadReconnectTime + "," + maintenanceWindowStartTime + "," + maintenanceWindowEndTime + "," + maintenanceWindowTimezone);
      log.info("Adding a new Global BISF Adapter Configuration Details");
      // Create the GlobalConfigDTO  to store the Global Adapter Configuration Details
      GlobalConfigDTO globalConfig = new GlobalConfigDTO();
      Long instanceID = null; // The generated id for the added configuration

      // Add the global Configuration information
      log.debug("Initialize the globalConfig Object.");
      globalConfig.setJMSRequestQueue(jmsRequestQueue);
      globalConfig.setJMSResponseTopic(jmsResponseTopic);
      globalConfig.setJMSNotificationRequestTopic(jmsNotificationRequestTopic);
      globalConfig.setJMSNotificationResponseQueue(jmsNotificationResponseQueue);
      globalConfig.setMaintenanceWindowStartTime(maintenanceWindowStartTime);
      globalConfig.setMaintenanceWindowEndTime(maintenanceWindowEndTime);
      globalConfig.setMaintenanceWindowTimezone(maintenanceWindowTimezone);

      if (!globalConfig.setJMSMessageTimeout(jmsMessageTimeout))
      {
         throw new ObjectCreationException ("Invalid value provied for the JMS Message Time out, Should be between 1 and 240");
      }
      if (!globalConfig.setProcessingTimeOut(processingTimeOut))
      {
         throw new ObjectCreationException ("Invalid value provied for the Processing Time out, Should be between 1 and 290");
      }
      if (!globalConfig.setThreadReconnectTime(threadReconnectTime))
      {
         throw new ObjectCreationException ("Invalid value provied for the Thread Reconnect Time, Should be greater than or equal to 1");
      }

      // Create the Session
      log.debug("Open Hibernate Session.");
      Session hibernateSession = hibernateSessionHelper.openSession();

      try
      {
         try
         {
            // Persist the BSIF Adapter Configuration information
            log.debug("Persist the BSIF Adapter Configuration information");
            instanceID = (Long) hibernateSession.save(globalConfig);
            hibernateSession.flush(); // Flush out the configuration
         }
         finally
         {
            // Close the Session and the JDBC Connection.
            log.debug("Close the JDBC Databse Connection.");
            hibernateSessionHelper.releaseConnection(hibernateSession.close());
         }
      }
      catch (HibernateException e)
      {
         throw new ObjectCreationException ("Could not save Global BSIFAdapter configuration Object: " + "(Caused by:" + e.getMessage() + ")");
      }
      catch (SQLException e)
      {
          throw new TWCSQLException("Error closing the JDBC connection while adding new BSIF Adapter Configuration" + e.getMessage());
      }
      log.trace("Exit from : addBSIFAdapter method with parameter(s) " + jmsRequestQueue + "," + jmsResponseTopic + "," + jmsNotificationRequestTopic + "," + jmsNotificationResponseQueue + "," + jmsMessageTimeout + "," + processingTimeOut + "," + threadReconnectTime + "," + maintenanceWindowStartTime + "," + maintenanceWindowEndTime + "," + maintenanceWindowTimezone);
      return instanceID.longValue(); // return  the generated id
   }


now when i add a record manually the getXXX() is not getting the record added from the backend.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 16, 2004 6:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
who is adding the record? a db client? your webapp?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 16, 2004 6:42 am 
Newbie

Joined: Fri Jul 16, 2004 5:50 am
Posts: 3
Location: Chennai, India
the prob is solved.

i did the following change in the code for getting the record

Transaction tx = hibernateSession.beginTransaction()
hibernateSession.setFlushMode(FlushMode.COMMIT);
List list = hibernateSession.find(queryString);
tx.commit();

and this code works..

Thanks a lot..
Senthil Kumar M Rangaswamy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.