List of usage examples for org.hibernate IdentifierLoadAccess load
T load(Serializable id);
From source file:org.musicrecital.dao.hibernate.GenericDaoHibernate.java
License:Apache License
/** * {@inheritDoc}//from w ww. ja v a 2s . c om */ @SuppressWarnings("unchecked") public T get(PK id) { Session sess = getSession(); IdentifierLoadAccess byId = sess.byId(persistentClass); T entity = (T) byId.load(id); if (entity == null) { log.warn("Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found..."); throw new ObjectRetrievalFailureException(this.persistentClass, id); } return entity; }
From source file:org.musicrecital.dao.hibernate.GenericDaoHibernate.java
License:Apache License
/** * {@inheritDoc}/* ww w .ja v a 2s . co m*/ */ @SuppressWarnings("unchecked") public boolean exists(PK id) { Session sess = getSession(); IdentifierLoadAccess byId = sess.byId(persistentClass); T entity = (T) byId.load(id); return entity != null; }
From source file:org.musicrecital.dao.hibernate.GenericDaoHibernate.java
License:Apache License
/** * {@inheritDoc}//from w w w . jav a 2 s. c om */ public void remove(PK id) { Session sess = getSession(); IdentifierLoadAccess byId = sess.byId(persistentClass); T entity = (T) byId.load(id); sess.delete(entity); }
From source file:vn.vnpttech.ssdc.nms.xmpp.connector.dao.XmppGenericDaoImpl.java
License:Apache License
@Override public T get(PK id) { Session session = getSession();//from w ww. ja v a 2s .c o m Transaction tx = null; try { IdentifierLoadAccess byId = session.byId(persistentClass); T entity = (T) byId.load(id); return entity; } catch (Exception e) { if (tx != null) { tx.rollback(); } e.printStackTrace(); return null; } finally { session.close(); } }