Opened 14 years ago
Closed 14 years ago
#1578 closed enhancement (fixed)
Add support for items as query parameters
Reported by: | Nicklas Nordborg | Owned by: | Nicklas Nordborg |
---|---|---|---|
Priority: | minor | Milestone: | BASE 2.17 |
Component: | core | Version: | |
Keywords: | Cc: |
Description
Eg. instead of
select s from SampleData s where s.id = :id
it would be possible to do
select s from SampleData s where s = :entity
and then in the code
query.setParameter("id", sample.getId());
can be replaced with
query.setParameter("entity", sample);
If we try the latter in the current version an exception is thrown:
java.lang.IllegalArgumentException: java.lang.ClassCastException@78ff22ed at sun.reflect.GeneratedMethodAccessor48.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:172) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:227) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3850) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:3558) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:203) at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242) at org.hibernate.type.ManyToOneType.disassemble(ManyToOneType.java:203) at org.hibernate.cache.QueryKey.generateQueryKey(QueryKey.java:107) at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2291) at org.hibernate.loader.Loader.list(Loader.java:2268) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at net.sf.basedb.core.hibernate.QueryWrapper.list(QueryWrapper.java:109) at net.sf.basedb.core.HibernateUtil.loadData(HibernateUtil.java:1462) at net.sf.basedb.core.AbstractHqlQuery.count(AbstractHqlQuery.java:165) at net.sf.basedb.core.AbstractEntityQuery.count(AbstractEntityQuery.java:234) at net.sf.basedb.core.ItemQuery.count(ItemQuery.java:40)
Change History (2)
comment:1 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Note:
See TracTickets
for help on using tickets.
(In [5564]) Fixes #1578: Add support for items as query parameters