Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Table of Contents

Java Basic Samples

...

Code Block
languagejava
titleSample: main construct
collapsetrue
String configFile           = "./hibernate.cfg.xml";
SOSHibernateFactory factory = null;
SOSHibernateSession session = null;

try
{
    factory = new SOSHibernateFactory(configFile);
    factory.build();
     
    // session = factory.openSession();     
    // session = factory.getCurrentSession();     
    session = factory.openStatelessSession();
     
    session.beginTransaction();
    ....
    session.commit();
} 
 
catch( Exception e ) 
{
    if ( session != null )
    {
        try
        {
            session.rollback();
        } 
 
		catch( Exception ex ) {}
	} 
    throw e;
}
finally
{
    if ( session != null )
    {
        session.close();
    }
    
    if ( factory != null )
    {
        factory.close();
    }
}
Code Block
languagejava
titleSample: session.scroll()
collapsetrue
...
ScrollableResults sr = null;

try
{
    // Query or NativeQuery
    Query<?> query = session.createQuery("from MY_DBITEM_ENTITY");
    sr = session.scroll(query);             
    while (sr.next()) {                 
        // do something with the current record            
    }
}

catch( Exception e )
{
    throw e;
}

finally
{
    if ( sr != null ){    
       sr.close(); 
    }
}             
...
Code Block
languagejava
titleSample: session.getSQLExecutor().getResultSet(String sql)
collapsetrue
...
executor = session.getSQLExecutor();
...    
ResultSet rs = null;

try
{
    rs = executor.getResultSet("select * from MY_TABLE");             
    Map<String, String> record = null;             
    while (!(record = executor.nextAsStringMap(rs)).isEmpty()) { //or ... executor.next(rs) ...               
        // do something with the current record            
    }
}

catch(Exception e)
{
    throw e;
}

finally
{
    executor.close(rs); 
}             
     
...

...

JavaScript

...

Job Samples

...