Hello,
I would like to map an array of booleans with the folllowing mapping:
Code:
<subclass name="hu.mobidiak.model2.MultiChoiceTestItem" discriminator-value="M">
<array name="correct" table="t_correct">
<key column="item_id"/>
<index column="i"/>
<element type="boolean" column="value" not-null="true"/>
</array>
</subclass>
I can save objects of this class using session.save() but when I try to reload an instance with session.load() the following exception is thrown:
Code:
2004-06-21 13:23:58,252 [main] ERROR net.sf.hibernate.property.BasicPropertyAccessor - IllegalArgumentException in class: hu.mobidiak.model2.MultiChoiceTestItem, setter method of property: correct
2004-06-21 13:23:58,254 [main] ERROR net.sf.hibernate.property.BasicPropertyAccessor - expected type: [Z, actual value: [Ljava.lang.Boolean;
2004-06-21 13:23:58,256 [main] ERROR hu.mobidiak.db2.PersistenceManager - net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of hu.mobidiak.model2.MultiChoiceTestItem.correct
net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of hu.mobidiak.model2.MultiChoiceTestItem.correct
at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:68)
at net.sf.hibernate.persister.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:221)
at net.sf.hibernate.impl.SessionImpl.initializeEntity(SessionImpl.java:2206)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:240)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:915)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:890)
at net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3264)
at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3119)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:955)
at net.sf.hibernate.loader.Loader.list(Loader.java:946)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:846)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at hu.mobidiak.db2.PersistenceManager.query(PersistenceManager.java:385)
at hu.mobidiak.db2.TestManager.getTest(TestManager.java:29)
at hu.mobidiak.db2.TestManager.getTest(TestManager.java:39)
at hu.mobidiak.test.TestPrinter.main(TestPrinter.java:130)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at net.sf.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:38)
... 21 more
The error occurs in the following environment: RedHat Linux 9, PostgreSQL 7.3.4 , HIbernate 2.1.4.
If I use an array of Booleans (Boolean[]) in the class instead of an array of primitive boolean values then everything goes fine. Is it a bug in the handling of boolean arrays?
Best regards,
Peter