/** * Create a class instance initialized with the given identifier * * @param id The identifier value to use (may be null to represent no value) * @param session The session from which the request originated. * * @return The instantiated entity. * * @deprecated (since 5.3) Use the form accepting SharedSessionContractImplementor * instead */ @Deprecated default Object instantiate(Serializable id, SessionImplementor session) { return instantiate( id, (SharedSessionContractImplementor) session ); }
@Override public Object instantiate(final Serializable id) throws HibernateException { return metadata.instantiate(id, getSessionImplementor()); }
/** * Construct an entity for the Hibernate object with given id. * * @param dataSourceName data source name * @param id object id */ public HibernateEntity(String dataSourceName, Object id) { metadata = sessionFactory.getClassMetadata(dataSourceName); if (id != null) { object = sessionFactory.getCurrentSession().get(dataSourceName, (Serializable) id); } if (object == null) { object = metadata.instantiate(null, (SessionImplementor) sessionFactory.getCurrentSession()); } }
@Override public Object newInstance() throws LayerException { try { return getEntityMetadata().instantiate(null, (SessionImplementor) getSessionFactory().getCurrentSession()); } catch (Exception e) { // NOSONAR throw new LayerException(e, ExceptionCode.HIBERNATE_CANNOT_CREATE_POJO, getFeatureInfo() .getDataSourceName()); } }
private Object createIndex(Content content) { ContentContainer container = content.getContainer(); if (container != null) { Object owner = container.getOwner(); if (owner != null) { String ownerClassName = Hibernate.getClass(owner).getName(); ClassMetadata meta = getIndexClassMetadata(ownerClassName); if (meta != null) { ContentIndex index = (ContentIndex) meta.instantiate(content.getId(), (SessionImplementor) sessionFactory.getCurrentSession()); String ownerProperty = StringUtils.uncapitalize(StringUtils.unqualify(ownerClassName)); meta.setPropertyValue(index, ownerProperty, owner); index.setContent(content); return index; } } } return null; }
@Override public Object newInstance(String id) throws LayerException { try { Serializable ser = (Serializable) ConvertUtils.convert(id, getEntityMetadata().getIdentifierType() .getReturnedClass()); return getEntityMetadata().instantiate(ser, (SessionImplementor) getSessionFactory().getCurrentSession()); } catch (Exception e) { // NOSONAR throw new LayerException(e, ExceptionCode.HIBERNATE_CANNOT_CREATE_POJO, getFeatureInfo() .getDataSourceName()); } }