List of usage examples for org.hibernate HibernateException HibernateException
public HibernateException(Throwable cause)
From source file:cn.guoyukun.spring.jpa.repository.hibernate.type.ObjectSerializeUserType.java
License:Apache License
/** * Hibernate??//w w w. java 2 s. com * ?PreparedStateme?? */ @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { ObjectOutputStream oos = null; if (value == null) { st.setNull(index, Types.VARCHAR); } else { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(value); oos.close(); byte[] objectBytes = bos.toByteArray(); String hexStr = Hex.encodeHexString(objectBytes); st.setString(index, hexStr); } catch (Exception e) { throw new HibernateException(e); } finally { try { oos.close(); } catch (IOException e) { } } } }
From source file:co.edu.udea.drai.expsw.modelo.dao.impl.UsuarioDAO.java
public Usuario registrarUsuario(Usuario usuario) throws HibernateException { Session session = null;// ww w. j av a 2s . com Transaction tx = null; try { session = (Session) HibernateSessionFactory.getInstance(); session.beginTransaction(); //session = new HibernateUtil().getSessionFactory().getCurrentSession(); session.getTransaction().commit(); tx = session.getTransaction(); tx.begin(); session.save(usuario); tx.commit(); session.flush(); } catch (HibernateException ex) { throw new HibernateException(ex); } finally { if (session != null) session.close(); } return usuario; }
From source file:com.anyuan.thomweboss.persistence.dao.HibernateDaoTemplate.java
License:Apache License
/** * ?hibernatejdbctransaction// w ww. j a v a 2 s . c om * @author Thomsen * @since Dec 15, 2012 11:20:02 PM * @return */ public static Transaction getTranscation() { Transaction transaction = null; try { Configuration configuration = new Configuration().configure(); // classpathhibernate.cfg.xml ServiceRegistry registry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()) .buildServiceRegistry(); SessionFactory sessionFactory = configuration.buildSessionFactory(registry); // hibernate4.0 ?buildSessionFactory() // Session session = sessionFactory.getCurrentSession(); session = sessionFactory.openSession(); transaction = session.beginTransaction(); } catch (HibernateException e) { e.printStackTrace(); } if (transaction == null) { throw new HibernateException("transaction is null"); } return transaction; }
From source file:com.app.gpo.dao.FieldDAO.java
License:Open Source License
public void update(Field field) throws HibernateException { try {/*ww w . j a v a2 s . c o m*/ saveUpdate(field); } catch (final HibernateException e) { throw new HibernateException(e); } }
From source file:com.app.gpo.dao.OrderItemDAO.java
License:Open Source License
public void update(OrderItem orderItem) throws HibernateException { try {// w w w. ja v a 2s .co m saveUpdate(orderItem); } catch (final HibernateException e) { throw new HibernateException(e); } }
From source file:com.app.gpo.dao.ProductionSlotDAO.java
License:Open Source License
public void update(ProductionSlot productionSlot) throws HibernateException { try {//from w w w .j a va2 s. c om saveUpdate(productionSlot); } catch (final HibernateException e) { throw new HibernateException(e); } }
From source file:com.app.inventario.dao.seguridad.IntentosLoginDAOImpl.java
private void manejaExcepcion(HibernateException he) throws HibernateException { tx.rollback();// www . j a v a 2s.c o m Logger.getLogger(IntentosLoginDAOImpl.class.getName()).log(Level.SEVERE, null, he); throw new HibernateException(he); }
From source file:com.app.inventario.dao.UsuarioDAOImpl.java
private void manejaExcepcion(HibernateException he) throws HibernateException { tx.rollback();/*from w w w .java2 s.co m*/ Logger.getLogger(UsuarioDAOImpl.class.getName()).log(Level.SEVERE, null, he); throw new HibernateException(he); }
From source file:com.atomikos.icatch.jta.hibernate3.AtomikosConnectionProvider.java
License:Apache License
public Connection getConnection() throws SQLException { if (dataSource == null) throw new HibernateException("datasource is not configured"); return dataSource.getConnection(); }
From source file:com.audoc.model.dbrelation.HibernateUtil.java
public void addSeanse(Object seanse) throws HibernateException { Session session = getOpenedSession(); Seanses s = (Seanses) seanse;/*from w w w . j ava 2 s . c o m*/ session.beginTransaction(); // String queryByDate="SELECT s FROM Seanses s where s.seansesTime like '"+s.getSeansesTime()+"%'"; // try{ // List<Seanses> res=ses.createQuery(queryByDate).list(); // if(res.isEmpty()){ session.save(s); try { session.getTransaction().commit(); // }else{ // if((JOptionPane.showConfirmDialog(null, "? ???"))==JOptionPane.YES_OPTION){ // ses.createNativeQuery("UPDATE seanses SET pacientName= " +s.getPacientName() // +", pacientPhone="+s.getPacientPhone()+" WHERE seansesTime=" // + s.getSeansesTime()); // ses.save(s); // tr.commit(); // } // } } catch (HibernateException e) { session.getTransaction().rollback(); throw new HibernateException("This time already exist."); } }