HibernateException.printStackTrace
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.hibernate.HibernateException.printStackTrace(Showing top 15 results out of 315)

  • Common ways to obtain HibernateException
private void myMethod () {
HibernateException h =
  • Throwable cause;new HibernateException(cause)
  • String message;new HibernateException(message)
  • String message;new HibernateException(message, cause)
  • AI code suggestions by Codota
}
origin: stackoverflow.com

private static SessionFactory seesionFactory = null;
 private static final SessionFactory makeSessionFactory()
 {
   try {
          if (sessionFactory==null)
     seesionFactory = new Configuration().configure().buildSessionFactory();
   } catch (HibernateException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
  return seesionFactory;    
 }
origin: stackoverflow.com

 public Integer search(HashMap<String, Object> params) {
  Session sesion = sessionFactory.openSession();
  Integer id = null;
  try{
    List lista = sesion.createCriteria(User.class).add(
        Restrictions.eq("name",(String)params.get("name"))).list();
    if(lista.size() == 1){id = ((User)lista.get(0)).getId();}
  }catch(HibernateException he){
    he.printStackTrace();
  }finally{sesion.close();}
  return id;
}
origin: stackoverflow.com

Session session=null;
  try {
   session =HibernateUtil.getSessionFactory().openSession();
 } catch (HibernateException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
 }finally
 {
   session.close();
 }
origin: stackoverflow.com

 } catch (HibernateException e) {
  if (tx != null) {
    try {
      tx.rollback();
    } catch(Exception re) {
      System.err.println("Error when trying to rollback transaction:"); // use logging framework here
      re.printStackTrace();
    }
  }
  System.err.println("Original error when executing query:"); // // use logging framework here

  e.printStackTrace();
}
origin: mifos/head

public void shutdown() {
  try {
    sessionFactory.close();
    sessionTL.remove();
    interceptorTL.remove();
  } catch (HibernateException e) {
    e.printStackTrace(System.out);
  }
  sessionFactory = null;
}
origin: stackoverflow.com

Session s = HibernateUtil.getSessionFactory().openSession();
 Transaction tx = null;
 try {
   tx = s.beginTransaction();        
   // here get object
   List<Employee> list = s.createCriteria(Employee.class).list();
   tx.commit();
 } catch (HibernateException ex) {
   if (tx != null) {
     tx.rollback();
   }            
   Logger.getLogger("con").info("Exception: " + ex.getMessage());
   ex.printStackTrace(System.err);
 } finally {
   s.close(); 
 }
origin: stackoverflow.com

 public User updateUser(User user) {

  try {
    User result = session.get(User.class, user.getId());
    if (result == null) {
      throw new FilamentNoSuchRecordException(new CoreError(304, "User does not exist"));
    }
    result.setName(user.getName()); // update some properties
    session.update(result); // you should update 'result', not 'user'

    return result;
  } catch (HibernateException e) {
    e.printStackTrace();
    throw new FilamentDataConnectivityException(new CoreError(305,"Connectivity issue. Please see System Administrator"));
  }

}
origin: stackoverflow.com

 private Session getSession(SessionFactory sessionFactory){
 Session session = null;
 try{
   session = sessionFactory.getCurrentSession();
 }catch(HibernateException hex){
   hex.printStackTrace();
 }
 if(session == null && !session.isClosed()){
   session = sessionFactory.openSession();
 }
}
origin: stackoverflow.com

public void addRolesToUser(Role roles,UserDao user) {
  try{ 
   session.beginTransaction();
    roles=new Role();
    user=new UserDao();
    user.getRoles().add(roles);
    session.save(roles);
    session.save(user);
    session.getTransaction().commit();
  }catch(HibernateException e){
    session.getTransaction().rollback();
    e.printStackTrace();
  }
 }
origin: stackoverflow.com

 Session session = HibernateUtil.getSession();
try {
  String hql = "FROM TreeNode tn JOIN tn.nodeAsset WHERE tn.id=5";
  Query query = session.createQuery(hql);
  List result = query.list();
  System.out.println("done");
} catch (HibernateException e) {
  e.printStackTrace();
  throw new Exception("Query failed", e);
} finally {
  session.flush();
  session.close();
}
origin: stackoverflow.com

 try {
  System.out.println("Begin transaction");
  session.beginTransaction();

  System.out.println("Save mortgage");
  session.save(mortgage);
  System.out.println("Commit transaction");
  session.getTransaction().commit();

  System.out.println("Close session");
  session.close();
  System.out.println("Close SessionFactory");
  HibernateUtil.getSessionFactory().close();
} catch (HibernateException he) {
  he.printStackTrace();
}
origin: stackoverflow.com

 public List<Car> findAll() {
  List<Car> carsList = new ArrayList<Car>();
  try {
    query = session.createQuery("from Car");
    carsList = query.list();
    for (Iterator iterator = carsList.iterator(); iterator.hasNext(); ) {
      Car car = (Car) iterator.next();
    }
  } catch (HibernateException he) {
    he.printStackTrace();
  } finally {

  }
  return carsList;
}
origin: stackoverflow.com

Session session=null;
 Transaction tx=null;
  try {
   session =HibernateUtil.getSessionFactory().openSession();
   tx=session.beginTransaction();
   } catch (HibernateException e) {
 e.printStackTrace();
 }finally
 {
   session.close();
 }
origin: stackoverflow.com

public void addGrade(Grade grade) {
 Session session = sessionFactory.getCurrentSession()
  Transaction tx = null;
  try{
  tx = session.beginTransaction();
  session.save(grade);   
  tx.commit();
   }catch (HibernateException e) {
    if (tx!=null) tx.rollback();
    e.printStackTrace(); 
  }finally {
    session.close(); 
  }
  }
origin: stackoverflow.com

 public static void setConnectionProperties() {
  URL configFileURL = null;

  try {
    configFileURL = URL_OF_YOUR_CFG_XML_FILE;
    configuration = (new Configuration()).configure(configFileURL);
    sessionFactory = configuration.buildSessionFactory();

  } catch (HibernateException e) {
    e.printStackTrace(); 
    System.out.println("Error while initializing hibernate: " + e.getMessage());
  }

}
org.hibernateHibernateExceptionprintStackTrace

Popular methods of HibernateException

  • <init>
    Constructs a HibernateException using the given message and underlying cause.
  • getMessage
  • getCause
  • getStackTrace
  • setStackTrace
  • toString

Popular classes and methods

  • getContentResolver (Context)
  • findViewById (Activity)
  • setRequestProperty (URLConnection)
    Sets the value of the specified request header field. The value will only be used by the current URL
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Menu (java.awt)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble

For IntelliJ IDEA and
Android Studio

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)