Pay attention to the data type in Hibernate

xiaoxiao2021-03-05  21

If you use the String type in Java to map to SQL Server's text (or NTEXT) type, be sure to specify the data type below, otherwise an error will appear.

If you don't explicitly specify the type, there will be a wrong prompt similar to:

Java.sql.sqlexception: The Amount of Data Read from the stres not = length.

at net.sourceforge.jtds.jdbc.ClobImpl.getSubString (ClobImpl.java:236) at net.sourceforge.jtds.jdbc.Support.convert (Support.java:308) at net.sourceforge.jtds.jdbc.JtdsResultSet.getString (JTDSRESRESRSET.JAVA: 879) at Net.SourceForge.jtds.jdbc.jtdsResultSet.getstring (jtdsResultSet.java: 1161) at Net.sf.hibernate.Type.StringType.get (StringType.java: 18) at Net.sf. hibernate.type.NullableType.nullSafeGet (NullableType.java:62) at net.sf.hibernate.type.NullableType.nullSafeGet (NullableType.java:53) at net.sf.hibernate.type.AbstractType.hydrate (AbstractType.java: 67) at Net.sf.hibernate.Loader.Loader.hydrate (loadinger.java: 690) at Net.sf.hibernate.Loader.Loader.LoadFromResultset (loadinger.java: 631) at Net.sf.hibernate.Loader.Loader .instancenotyetloaded (loadinger.java:590) at net.sf.hibernate.loader.Loader.Getrow (loader.java: 505) at Net.sf.hibaRNate.Loader.Loader.gtrowFromResultset (loader.java: 218) at Net. sf.hibernate.loader.loader.doquery (loadinger.java: 285) at Net.sf.hibernate.Loader.Loader.doQueryandInitiali ZenonlazyCollections (loader.java: 138) at net.sf.hibernate.loader.Loader.dolist (loadinger.java:1063) at Net.sf.hibernate.Loader.Loader.list (loadinger.java:1054) at net.sf .hibernate.hql.QueryTranslator.list (QueryTranslator.java:854) at net.sf.hibernate.impl.SessionImpl.find (SessionImpl.java:1554) at net.sf.hibernate.impl.QueryImpl.list (QueryImpl.java : 49)

转载请注明原文地址:https://www.9cbs.com/read-36805.html

New Post(0)