imagedb is write by jdbc example:
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?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); } } ); }
such as a domain object MyFile contain:
and in DAO ,directly useCode:InputStream contentStream; public InputStream getContentStream() { return contentStream; } public void setContentStream(InputStream contentStream) { this.contentStream = contentStream; }
???Code:public void addMyFile (MyFile file) { getHibernateTemplate().save(file); }


Reply With Quote