Forums Register Login

Could not read the data

+Pie Number of slices to send: Send
HI All,
I am getting below ClassCastException only for particular data.It is working fine with other data.I could not able to understand whats wrong with my mapping files.If anyone cameacrross these types of problems please help me.I am using Hibernate 2.1.1

1.The Mapping for that coloumn in my hbm file is like below
<property
name="assetNum"
type="long"
column="ASSET_NUM"
not-null="true"
length="15"
/>

2. The Exception that i am getting is,
java.lang.ClassCastException: java.lang.Long incompatible with java.lang.Short
at net.sf.hibernate.type.ShortType.set(ShortType.java:30)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:673)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:712)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:184)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:830)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:850)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:57)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:49)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:420)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2044)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:1918)
at net.sf.hibernate.impl.SessionImpl.internalLoadOneToOne(SessionImpl.java:1872)
at net.sf.hibernate.type.OneToOneType.resolveIdentifier



Thnaks,
Gundeti.
+Pie Number of slices to send: Send
We'd need to see your Java object to be sure, but most likely you declared assetNum as a Short (or short). Change it to a Long (or change your xml mapping to a short). The xml mapping needs to be consistent with the actual data type.

Carl
+Pie Number of slices to send: Send
asset_num filed is delcared as required. But i am getting this exception only for particula data.
Please see the below code which says how i am using,


[ Edited to use code tags - Paul Sturrock ]
[ September 25, 2008: Message edited by: Paul Sturrock ]
+Pie Number of slices to send: Send
Perhaps you are getting the exception only when the value is too wide to fit in a short.

Post your POJO (java class) and complete XML mapping.

Carl
+Pie Number of slices to send: Send
We are passing only long values to assetNum filed but somehow hibernate is converting it into short type.Thats why i am getting this exception. This problem occuring only for few valuses.For example if pass the value 10000970 for assetNum field, the hibernate is trying to convert it to short type.

1.For your reference the POJO class is


2. The hbm file is,


[ Edited to use code tags - Paul Sturrock ]
[ September 25, 2008: Message edited by: Paul Sturrock ]
+Pie Number of slices to send: Send
Its urgent.any help on this.
The fastest and most reliable components of any system are those that are not there. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1351 times.
Similar Threads
many-to-one and Set problem
problem using hibernate and stored procedures for reading portion of data from database
invalid colum name GenericJDBCException: could not execute query
could not initialize a collection+ [Microsoft][ODBC SQL Server Driver]Invalid Descrip
Problem in SP Calling using Hibernate
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:05:22.