I get SQLExceptions when initializing an indexed collection. The generated sql is correct but the code that reads the result set mistakes the index column as a serializable type.
notice that this used to work with hibernate3.1b3 and annotations b5
The collection mapping is:
@OneToMany( cascade = CascadeType.ALL, mappedBy="node")
@MapKey(name="lang")
@JoinColumn(name="treeid", nullable = false)
protected Map<Language, MetaData> metadata;
and the Language object id is a Long.
Hibernate version:
3.1 rc1
The generated statement
select metadata0_.treeid as treeid2_, metadata0_.id as id2_, metadata0_.langid as formula0_2_, metadata0_.id as id11_1_, metadata0_.langid as langid11_1_, metadata0_.treeid as treeid11_1_, metadata0_.title as title11_1_, metadata0_.description as descript3_11_1_, metadata0_.keywords as keywords11_1_, metadata0_.image as image11_1_, language1_.id as id4_0_, language1_.code as code4_0_, language1_.description as descript3_4_0_, language1_.isDefault as isDefault4_0_ from tmetadata metadata0_ left outer join tlang language1_ on metadata0_.langid=language1_.id where metadata0_.treeid=?
Full stack trace of any exception that occurs:
Caused by: java.sql.SQLException: Unable to convert between java.lang.Integer and BINARY.
at net.sourceforge.jtds.jdbc.Support.convert(Support.java:558)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getBytes(JtdsResultSet.java:714)
at net.sourceforge.jtds.jdbc.JtdsResultSet.getBytes(JtdsResultSet.java:988)
at org.jboss.resource.adapter.jdbc.WrappedResultSet.getBytes(WrappedResultSet.java:238)
at org.hibernate.type.BinaryType.get(BinaryType.java:66)
at org.hibernate.type.SerializableType.get(SerializableType.java:34)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:113)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:102)
at org.hibernate.persister.collection.AbstractCollectionPersister.readIndex(AbstractCollectionPersister.java:650)
at org.hibernate.collection.PersistentMap.readFrom(PersistentMap.java:222)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:994)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:635)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:579)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLa
Name and version of the database you are using:
MS SQL SERVER 2000 sp3
jtds driver version 1.1.
|