- This topic has 4 replies, 3 voices, and was last updated 17 years, 3 months ago by
awamser.
-
AuthorPosts
-
awamserMemberMSSQL 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.
chapter2MemberI’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?
Brian FernandesModeratorIf 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 onceThis is documented further in section 5.4 the Hibernate Tutorial in the included documentation.
Do let us know if you require further assistance.
awamserMemberI 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
awamserMemberjTDS driver works fine… helps when the image column in the database isn’t null. Can view the images with out issue!
Thanks!
-
AuthorPosts