facebook

Mapping MSSQL image datatype

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #277452 Reply

    awamser
    Member

    MSSQL database contains a column (AF_Photo_1) with a datatype of image. The reverse mapping tool maps with as java.lang.String.

    <key-property name=”afPhoto1″ type=”java.lang.String”>
    <column name=”AF_Photo_1″ />
    </key-property>

    I’m not having luck finding in docs on how to handle this. With Oracle accessing BLOB/CLOB that contain images is pretty easy.

    I’ve only used Oracle database so I have no exp with MS-SQL.

    #277478 Reply

    chapter2
    Member

    I’m using MyEclipse 6.0.1GA, JPA backed by Hibernate, /w MS SQL Server. I’m using this driver http://jtds.sourceforge.net/typemap.html

    I’m also have an issue with mapping a database type of text to java.sql.Clob

    Any work around for this?

    #277522 Reply

    Brian Fernandes
    Moderator

    If the default mapping isn’t mapping to the desired type, you can use page 2 to specify the type mapping you would like for standard SQL data types.

    If the data type being mapped from is not standard (like Image), you can use page 3 of the RE wizard to select the column and explicitly specify the type you desire in the Hibernate type field.
    These settings need to be made only once

    This is documented further in section 5.4 the Hibernate Tutorial in the included documentation.

    Do let us know if you require further assistance.

    #277544 Reply

    awamser
    Member

    I edited the hbm.xml file and changed the data type to the following.

    <property name=”afPhoto1″ type=”java.sql.Blob”>
    <column name=”AF_Photo_1″ />
    </property>

    I’m using the driver jTDS and the docs have that the conversion is image -> java.sql.Blob.

    -> http://jtds.sourceforge.net/typemap.html

    looking at the log files i get the following

    36781 [http-8888-Processor25] DEBUG org.hibernate.connection.DriverManagerConnectionProvider – returning connection to pool, pool size: 1
    36781 [http-8888-Processor25] DEBUG com.xxxxx.employeesearch.struts.action.ViewPictureAction – Employee: John
    36781 [http-8888-Processor25] DEBUG com.xxxxx.employeesearch.struts.action.ViewPictureAction – Downloading photo for: JOHN DOE
    36781 [http-8888-Processor25] ERROR com.xxxxx.employeesearch.struts.action.ViewPictureAction – Error downloading employee photo: null

    #277547 Reply

    awamser
    Member

    jTDS driver works fine… helps when the image column in the database isn’t null. Can view the images with out issue!

    Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Mapping MSSQL image datatype

You must be logged in to post in the forum log in