Announcement Announcement Module
Collapse
No announcement yet.
Can i use getHibernateTemplate() to save Blob filed?? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can i use getHibernateTemplate() to save Blob filed??

    imagedb is write by jdbc example:

    Code:
    public void storeImage(
    	    final String name, final InputStream contentStream, final int contentLength, final String description)
    	    throws DataAccessException {
    		getJdbcTemplate().execute(
    				"INSERT INTO imagedb (image_name, content, description) VALUES (?, ?, ?)",
    				new AbstractLobCreatingPreparedStatementCallback(this.lobHandler) {
    					protected void setValues(PreparedStatement ps, LobCreator lobCreator) throws SQLException {
    						ps.setString(1, name);
    						lobCreator.setBlobAsBinaryStream(ps, 2, contentStream, contentLength);
    						lobCreator.setClobAsString(ps, 3, description);
    						
    					}
    				}
    		);
    	}
    but not best to me, i want to use hibernate to perform this function, so i must extends JdbcDaoSupport in my DAO?? can i use getHibernateTemplate() to perform this function?

    such as a domain object MyFile contain:

    Code:
        InputStream contentStream;
    	
        public InputStream getContentStream() {
            return contentStream;
        }
        public void setContentStream(InputStream contentStream) {
            this.contentStream = contentStream;
        }
    and in DAO ,directly use
    Code:
        public void addMyFile (MyFile file) {
            getHibernateTemplate().save(file);
        }
    ???

  • #2
    Spring - Hibernate allow for CLOB / BLOB management. Search the forums for Hibernate / Oracle / CLOB or BLOB.

    Comment

    Working...
    X