The type in the MySQL database is Longblob
Entity class defined as: byte[] Type
The mapping file is configured as: type= "Org.springframework.orm.hibernate3.support.BlobByteArrayType
Exception information:
1 for JDBC Type:-42at org.hibernate.dialect.TypeNames.get (typenames.java:56)3 at Org.hibernate.dialect.TypeNames.get (typenames.java:81)4at Org.hibernate.dialect.Dialect.getHibernateTypeName (dialect.java:370)5at Org.hibernate.loader.custom.customloader$metadata.gethibernatetype (customloader.java:559)
Workaround:
1. Add Registration class:
1 Packagecom.prochanges.framework.utils;2 3 Importjava.sql.Types;4 5 Importorg.hibernate.Hibernate;6 ImportOrg.hibernate.dialect.MySQL5Dialect;7 8 Public classBlobmysqldialectextendsMysql5dialect {9 PublicBlobmysqldialect () {Ten Super(); OneRegisterhibernatetype (Types.longvarbinary, Hibernate.BLOB.getName ());//the value of registering Blob,types.longvarbinary is-4 A } -}
2. Modify the value of the Hibernate.dialec property of the database in the configuration file, that is, the newly-written registration class:
<prop key= "Hibernate.dialect" >com.prochanges.framework.utils.BlobMySQLDialect</prop>
No dialect mapping for JDBC type–4 hibernate querying MySQL for LONGBLOB data