Results 1 to 2 of 2

Thread: Can i use getHibernateTemplate() to save Blob filed??

  1. #1
    Join Date
    Nov 2004
    Posts
    16

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    Spring - Hibernate allow for CLOB / BLOB management. Search the forums for Hibernate / Oracle / CLOB or BLOB.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

Similar Threads

  1. insert blob and return generated key
    By caverns in forum Data
    Replies: 1
    Last Post: Jul 10th, 2006, 01:43 PM
  2. HibernateTemplate Save does not work
    By lnader in forum Data
    Replies: 13
    Last Post: Jun 22nd, 2005, 06:46 AM
  3. Replies: 1
    Last Post: May 5th, 2005, 04:34 AM
  4. Replies: 3
    Last Post: Jan 31st, 2005, 08:52 AM
  5. Insert Blob into Oracle DB
    By pughbri in forum Data
    Replies: 9
    Last Post: Oct 11th, 2004, 03:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •