Java 类org.hibernate.LobHelper 实例源码

项目:openeos    文件:AttachmentUtils.java   
public static Blob createBlob(LobHelper lobHelper, InputStream origInputStream) {
    try {
        final File file = File.createTempFile(TEMP_PREFIX, TEMP_SUFFIX);
        OutputStream out = new FileOutputStream(file);
        IOUtils.copy(origInputStream, out);
        out.close();
        origInputStream.close();
        long len = file.length();
        file.deleteOnExit();
        InputStream in = new FileInputStream(file) {

            @Override
            public void close() throws IOException {
                super.close();
                file.delete();
            }

        };
        return lobHelper.createBlob(in, len);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
项目:LivingDocumentsServer    文件:DocumentServiceImpl.java   
@Override
@Transactional
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();
}
项目:lams    文件:SessionImpl.java   
@Override
public LobHelper getLobHelper() {
    if ( lobHelper == null ) {
        lobHelper = new LobHelperImpl( this );
    }
    return lobHelper;
}
项目:lams    文件:SessionDelegatorBaseImpl.java   
@Override
public LobHelper getLobHelper() {
    return session.getLobHelper();
}
项目:esup-sgc    文件:BigFile.java   
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); 
}
项目:esup-sgc    文件:BigFile.java   
public void setBinaryFile(byte[] bytes) {       
    if (this.entityManager == null) this.entityManager = entityManager();
    Session session = (Session) this.entityManager.getDelegate(); 
    LobHelper helper = session.getLobHelper(); 
    this.binaryFile = helper.createBlob(bytes); 
}
项目:esup-dematec    文件:BigFile.java   
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); 
}