Hello,
I'm having the error in the title, and I can't guess what I could be doing wrong.
I have an entity called AuditEvent. This entity has, among others, the following properties (the other properties are "common" ones, like Date, Strings etc):
Code:
@ElementCollection(fetch=EAGER)
@Fetch(SUBSELECT)
private List<String> params;
...
@ManyToOne
private EUser user;
The EUser entity has a @Any property defined as follows:
Code:
@Any(metaColumn = @Column(name = "referer_type", nullable = true), fetch = FetchType.EAGER)
@AnyMetaDef(idType = "long", metaType = "string", metaValues = {
@MetaValue(value = "H", targetEntity = Holding.class),
@MetaValue(value = "Co", targetEntity = Company.class),
@MetaValue(value = "D", targetEntity = Distributor.class),
@MetaValue(value = "A", targetEntity = Agency.class),
@MetaValue(value = "C", targetEntity = Creditor.class),
@MetaValue(value = "B", targetEntity = Banq.class) })
@JoinColumn(name = "myreferer_id")
@NotAudited
private UserReferrer referer;
In a given moment, I'm executing the following HQL on it:
Code:
from AuditEvent
where domain = :domain
and severity = :severity
and eventDate between :dateStart and :dateEnd
and user.referer in (:owners)
I'm setting all parameters, and also defining a firstResult and a maxResults in order to paginate the display of the results. The generated SQL that I see in my log is the following;
Code:
select params0_.AuditEvent_id as AuditEvent1_0_0_, params0_.params as params0_
from AuditEvent_params params0_
where params0_.AuditEvent_id in
(select auditevent0_.id
from AuditEvent auditevent0_
cross join EUser euser1_
where auditevent0_.user_id=euser1_.id
and auditevent0_.domain=?
and auditevent0_.severity=?
and (auditevent0_.eventDate between ? and ?)
and (euser1_.referer_type=? and euser1_.myreferer_id=?
or euser1_.referer_type=? and euser1_.myreferer_id=?))
When it's executed, I receive the error in the title. Here's the Hibernate stack trace:
Code:
Caused by: org.hibernate.exception.DataException: could not load collection by subselect: [fr.extelia.smdt.entities.AuditEvent.params#<1119, 1116>]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:102)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2244)
at org.hibernate.loader.collection.SubselectCollectionLoader.initialize(SubselectCollectionLoader.java:80)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:627)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1863)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:479)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:900)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:279)
at org.hibernate.loader.Loader.doList(Loader.java:2542)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365)
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 fr.extelia.smdt.daoimpl.AuditEventDAOImpl.find(AuditEventDAOImpl.java:102)
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:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
... 83 more
Caused by: org.postgresql.util.PSQLException: No value specified for parameter 8.
at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:178)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:246)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:498)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:386)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:271)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2238)
... 107 more
Does anyone have any idea of what's going on, and if there's a workaround or an actual fix for this?
Thank you!