List of usage examples for org.hibernate HibernateException HibernateException
public HibernateException(String message, Throwable cause)
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
@SuppressWarnings("unchecked") @Override/*w w w .j ava 2 s .co m*/ public List<App> getApplicationsForOrg(String orgName) { log.info("Getting all application for org " + orgName); List<App> apps = null; Session session = null; Transaction transaction = null; try { session = ServiceFactory.getHibernateSession(); transaction = session.beginTransaction(); Query query = session.createQuery( "from App as m where m.orgName= :orgName" + " and m.deleted = false order by m.appName asc"); query.setParameter("appOwnerName", orgName); apps = (List<App>) query.list(); transaction.commit(); } catch (HibernateException e) { throw new HibernateException("Cannot get applications ", e); } return apps; }
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
@Override public boolean isNameAvailable(String appName, String appOwner) throws HibernateException { if (appName == null || appName.length() == 0 || appOwner == null || appOwner.length() == 0) { log.error("Empty or Null name can not be checked for availability"); return false; }/*from w w w . ja v a2 s. c om*/ log.info("Checking for App with name : " + appName + " for owner " + appOwner); Session session = null; Transaction transaction = null; try { session = ServiceFactory.getHibernateSession(); transaction = session.beginTransaction(); Query query = session.createQuery("from App as m where m.appName = :name and m.appOwner = :owner"); query.setParameter("name", appName); query.setParameter("owner", appOwner); App result = (App) query.uniqueResult(); transaction.commit(); if (result != null) return false; else return true; } catch (HibernateException e) { transaction.rollback(); throw new HibernateException("Cannot check for name availability ", e); } }
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
public Long saveNetworkCarrier(NetworkCarrier carrier) throws HibernateException { Session session = null;/* ww w. ja va 2s .c o m*/ Transaction transaction = null; try { Date d = new Date(); session = ServiceFactory.getHibernateSession(); transaction = session.beginTransaction(); Long generatedId = (Long) session.save(carrier); transaction.commit(); log.info("Network Carrier " + generatedId + " saved"); return generatedId; } catch (HibernateException e) { log.error(e); transaction.rollback(); throw new HibernateException("Cannot save Network carrier.", e); } }
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
public Long saveNetworkSpeed(NetworkSpeed speed) throws HibernateException { Session session = null;/*from w w w .ja v a 2 s . c om*/ Transaction transaction = null; try { Date d = new Date(); session = ServiceFactory.getHibernateSession(); transaction = session.beginTransaction(); Long generatedId = (Long) session.save(speed); transaction.commit(); log.info("Network Speed " + generatedId + " saved"); return generatedId; } catch (HibernateException e) { log.error(e); transaction.rollback(); throw new HibernateException("Cannot save Network Speed.", e); } }
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
public Long saveDeviceModel(DeviceModel model) throws HibernateException { Session session = null;/*from w w w . j a v a 2 s .c o m*/ Transaction transaction = null; try { Date d = new Date(); session = ServiceFactory.getHibernateSession(); transaction = session.beginTransaction(); Long generatedId = (Long) session.save(model); transaction.commit(); log.info("Device Model " + generatedId + " saved"); return generatedId; } catch (HibernateException e) { log.error(e); throw new HibernateException("Cannot save Device model.", e); } }
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
public Long saveDevicePlatform(DevicePlatform platform) throws HibernateException { Session session = null;//from w w w .j a v a 2s . com Transaction transaction = null; try { Date d = new Date(); session = ServiceFactory.getHibernateSession(); transaction = session.beginTransaction(); Long generatedId = (Long) session.save(platform); transaction.commit(); log.info("Device Model " + generatedId + " saved"); return generatedId; } catch (HibernateException e) { log.error(e); transaction.rollback(); throw new HibernateException("Cannot save Device platform.", e); } }
From source file:org.apache.usergrid.apm.service.ApplicationServiceImpl.java
License:Apache License
@SuppressWarnings("unchecked") @Override/*from w w w. j a v a 2 s.co m*/ public List<NetworkCarrier> getNetworkCarriers(Long appId) throws HibernateException { log.info("Getting all network carriers"); List<NetworkCarrier> cs = null; Session session = null; Transaction transaction = null; try { session = ServiceFactory.getHibernateSession(); transaction = session.beginTransaction(); Query query = session.createQuery("from NetworkCarrier"); cs = (List<NetworkCarrier>) query.list(); transaction.commit(); } catch (HibernateException e) { transaction.rollback(); throw new HibernateException("Cannot get NetworkCarriers. ", e); } return cs; }