Pretty sure this is a bug...I have a class Report which extends Product with InheritanceType.JOINED and Product has a OneToMany of categories. Any time I try to query based on the categories I get the following exception.
Thanks
Query query = session().createQuery(
"SELECT p.report FROM "
+ ReportPurchase.class.getName() + " p "
+ "WHERE p.report.categories IN (:categories) ");
query.setParameterList("categories", categories);
public class ReportPurchase
@NotNull
@ManyToOne
private Report report;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Searchable
public class Report extends Product
public class Product
@OneToMany
@Cascade( { CascadeType.ALL, CascadeType.DELETE_ORPHAN })
Set<Category> categories = new HashSet<Category>();
Hibernate version: 3.2.0 CR2
Full stack trace of any exception that occurs:
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2147)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2028)
at org.hibernate.loader.Loader.list(Loader.java:2023)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:393)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at com.researchjunction.service.hibernate.HibernateReportService.findBestSellingReports(HibernateReportService.java:214)
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:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:334)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:209)
at $Proxy45.findBestSellingReports(Unknown Source)
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:585)
at wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:377)
at wicket.proxy.$Proxy50.findBestSellingReports(Unknown Source)
at com.researchjunction.panel.BestSellingReportsPanel.<init>(BestSellingReportsPanel.java:26)
at com.researchjunction.page.guest.ReportPage.init(ReportPage.java:137)
at com.researchjunction.page.guest.ReportPage.<init>(ReportPage.java:72)
at com.researchjunction.page.administrator.ReviewReports$1.onClick(ReviewReports.java:76)
at common.wicket.component.LinkPropertyColumn$LinkPanel$1.onClick(LinkPropertyColumn.java:53)
at wicket.markup.html.link.Link.onLinkClicked(Link.java:254)
... 34 more
Caused by: java.sql.SQLException: No value specified for parameter 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1530)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1478)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1199)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1668)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2144)
... 65 more
Name and version of the database you are using: mysql 5.1
The generated SQL (show_sql=true):
Hibernate: select report1_.id as id37_, report1_.title as title37_, report1_.description as descript4_37_, report1_.manufacturer_id as manufac18_37_, report1_.visitors as visitors37_, report1_.createdDate as createdD6_37_, report1_.updatedDate as updatedD7_37_, report1_.reportDraft_id as reportD19_37_, report1_.subTitle as subTitle37_, report1_.excerpt as excerpt37_, report1_.pages as pages37_, report1_.author as author37_, report1_.tableOfContents as tableOf12_37_, report1_.publishedDate as publish13_37_, report1_.rating as rating37_, report1_.companiesMentioned as compani15_37_, report1_.executiveSummaryPdf as executi16_37_, report1_.pdf as pdf37_, report1_.category_id as category20_37_, report1_.alternateCategory_id as alterna21_37_ from reportPurchases reportpurc0_ inner join products report1_ on reportpurc0_.report_id=report1_.id, products_categories categories3_, categories category4_ where report1_.id=categories3_.products_id and categories3_.categories_id=category4_.id and (. in (?))
|