[hibernate-issues] [Hibernate-JIRA] Updated: (HHH-2491) criteria failing with custom user type
Luca Dall'Olio (JIRA)
noreply at atlassian.com
Wed Mar 14 07:51:08 EDT 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2491?page=all ]
Luca Dall'Olio updated HHH-2491:
--------------------------------
Attachment: criteriacustomusertype.zip
Inside the attachment a working junit reproducing this issue
> criteria failing with custom user type
> --------------------------------------
>
> Key: HHH-2491
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2491
> Project: Hibernate3
> Type: Bug
> Environment: hibernate 3.2.2-GA hsqldb 8.0.1
> Reporter: Luca Dall'Olio
> Attachments: criteriacustomusertype.zip
>
>
> When executing a criteria query with a custom <id> type, hibernate ignores the custom type trying to set a primitive type instead; whereas load() works succesfully :
> Below is some code that helps reproducing this problem :
> Example of a custom Identifier Generator :
> package sample;
> ...
> public class CustomIdentifierGenerator implements IdentifierGenerator, PostInsertIdentifierGenerator, Configurable {
> private static IdentityGenerator hibernateGeneratorDelegate = null;
> public void configure(Type type, Properties props, Dialect dialect)
> throws MappingException {
> hibernateGeneratorDelegate = IdentifierGeneratorFactory.create(
> "sequence", new LongType(), props, dialect);
> if (hibernateGeneratorDelegate instanceof Configurable) {
> ((Configurable) hibernateGeneratorDelegate).configure(
> new LongType(), props, dialect);
> }
> }
> public Serializable generate(SessionImplementor session, Object object)
> throws HibernateException {
> return hibernateGeneratorDelegate.generate(session, object);
> }
> public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(
> PostInsertIdentityPersister persister, Dialect dialect,
> boolean isUseGet) throws HibernateException {
> return hibernateGeneratorDelegate.getInsertGeneratedIdentifierDelegate(persister, dialect, isUseGet);
> }
> }
> Mapping snippet :
> <class
> name="sample.SimpleEntity"
> table="TB_SMP_SIMPLE">
> <id name="entityPK" type="sample.LongEntityPK" column="SMP_ID">
> <generator class="sample.CustomIdentifierGenerator" />
> </id>
> </class>
> Entity class :
> package sample;
> ....
> public class SimpleEntity {
> Query code :
> SimpleEntity de = new SimpleEntity();
> s.save(de);
> // Read
> SimpleEntity de2 = (SimpleEntity) s.load(SimpleEntity.class, de
> .getEntityPK());
> assertNotNull(de2);
> assertEquals(de, de2);
> // Query
> Criteria crit = s.createCriteria(SimpleEntity.class);
> List results = crit.list(); // FAILING!!! IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK
> // expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long
> Logs :
> IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK
> expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long
> Error StackTrace:
> org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK
> at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
> at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211)
> at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:353)
> at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3600)
> at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1275)
> ...
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.IllegalArgumentException: argument type mismatch
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
> ... 35 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list