List of usage examples for org.hibernate Session getLobHelper
LobHelper getLobHelper();
From source file:de.hska.ld.content.service.impl.DocumentServiceImpl.java
License:Apache License
@Override @Transactional// ww w . j a va2 s .c o m public Long addAttachment(Long documentId, InputStream is, String fileName, long fileSize) { Document document = findById(documentId); if (document == null) { throw new ValidationException("id"); } checkPermission(document, Access.Permission.WRITE); Attachment attachment = new Attachment(fileName); Session session = (Session) em.getDelegate(); LobHelper lobHelper = session.getLobHelper(); Blob dataBlob = lobHelper.createBlob(is, fileSize); FileBlobBean fileBlobBean = new FileBlobBean(); fileBlobBean.setSourceBlob(dataBlob); attachment.setFileBlobBean(fileBlobBean); attachment.setCreator(Core.currentUser()); document.getAttachmentList().add(attachment); document = super.save(document); createNotifications(document, Subscription.Type.ATTACHMENT); return document.getAttachmentList().get(document.getAttachmentList().size() - 1).getId(); }
From source file:fr.univrouen.poste.domain.BigFile.java
License:Apache License
public void setBinaryFileStream(InputStream inputStream, long length) { if (this.entityManager == null) this.entityManager = entityManager(); Session session = (Session) this.entityManager.getDelegate(); LobHelper helper = session.getLobHelper(); this.binaryFile = helper.createBlob(inputStream, length); }
From source file:nl.strohalm.cyclos.dao.BaseDAOImpl.java
License:Open Source License
public Blob createBlob(final InputStream stream, final int length) { return getHibernateTemplate().execute(new HibernateCallback<Blob>() { public Blob doInHibernate(final Session session) throws HibernateException, SQLException { return session.getLobHelper().createBlob(stream, length); }/*from w w w . ja va 2s . c om*/ }); }
From source file:org.eclipse.emf.cdo.server.internal.hibernate.HibernateCDOPackageUnitDTO.java
License:Open Source License
public void setEPackageByteArray(Session session, byte[] ePackageByteArray) { this.ePackageByteArray = ePackageByteArray; ePackageBlob = session.getLobHelper().createBlob(ePackageByteArray); }
From source file:org.rhq.enterprise.server.drift.JPADriftServerBean.java
License:Open Source License
@Override @TransactionAttribute(REQUIRES_NEW)/*from w ww . j a v a2 s .co m*/ public void persistDriftFileData(JPADriftFile driftFile, InputStream data, long numBytes) throws Exception { JPADriftFileBits df = entityManager.find(JPADriftFileBits.class, driftFile.getHashId()); if (null == df) { throw new IllegalArgumentException("JPADriftFile not found [" + driftFile.getHashId() + "]"); } Session session = (Session) entityManager.getDelegate(); df.setDataSize(numBytes); df.setData(session.getLobHelper().createBlob(new BufferedInputStream(data), numBytes)); df.setStatus(LOADED); }