hibernate is not supported for the text data type of the database.
Hibernate is good when using the HQL query to include the text Type field. If you use native SQL, which is when querying the text type using the Createsqlquery method, you always get an error:
Org.hibernate.MappingException:No dialect mapping for JDBC type:-1
Atorg.hibernate.dialect.TypeNames.get (typenames.java:56)
There was a problem with the JDBC driver for hibernate with MySQL: the MySQL text type jdbc Resultsetmetadata.getcolumntype returns-1, and Hibernate does not register the type, So the Createsqlquery reported No dialect mapping for Jdbctype:-1.
Workaround:
1, write a class integrated dialect, and then achieve their own support for text
Import Java.sql.Types; Import Org.hibernate.dialect.MySQL5Dialect; public class Dialectforinkfish extends Mysql5dialect {public dialectforinkfish () { super (); Registerhibernatetype (Types.longvarchar, 65535, "text"); } }
2.
Modify Hibernate config file Hibernate.cfg.xml, put
<property name= "dialect" >org.hibernate.dialect.MySQL5Dialect</property>
modified to:
No dialect mapping for JDBC type: 1 workaround for text annotations to database in Hibernate