List of usage examples for org.hibernate Session byId
<T> IdentifierLoadAccess<T> byId(Class<T> entityClass);
From source file:org.zanata.action.ProjectHome.java
License:Open Source License
@Override protected HProject loadInstance() { Session session = (Session) getEntityManager().getDelegate(); if (projectId == null) { HProject project = (HProject) session.byNaturalId(HProject.class).using("slug", getSlug()).load(); validateProjectState(project);/*from w w w . j a v a2s .com*/ projectId = project.getId(); return project; } else { HProject project = (HProject) session.byId(HProject.class).load(projectId); validateProjectState(project); return project; } }
From source file:vn.vnpttech.ssdc.nms.xmpp.connector.dao.XmppGenericDaoImpl.java
License:Apache License
@Override public T get(PK id) { Session session = getSession(); Transaction tx = null;//ww w . j a v a 2 s. c o m 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(); } }