Ich bin recht neu bei Hibernate und sehr positiv überrascht von den Features
Ich versuche gerade eine Query (mittels Criteria) über ein Entität zu bescreiben, welche in-Klasuel benutzt.
Hibernate version:
3.2.5.g
Mapping documents:
@Entity
@Table(name="keyword")
public class Keyword
{
@CollectionOfElements(fetch=FetchType.LAZY)
Set<Category> categories=new HashSet<Category>();
...
}
@Entity
@Table(name="category")
public class Category
{
@Id
@GeneratedValue(generator="guidgenerator")
@Column(nullable=false, length=256)
private String guid;
}
Code between sessionFactory.openSession() and session.close():
Category myCat = getHibernateTemplate().get(Category.class, aGUID);
if (myCat!=null)
{
DetachedCriteria _query = DetachedCriteria.forClass(Keyword.class);
_query=_query.add(Restrictions.in("categories", new Category[]{myCat}));
List _l = getHibernateTemplate().findByCriteria(_query);
}
Full stack trace of any exception that occurs:
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.DataException: could not execute query
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:616)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:378)
at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:981)
at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:974)
at org.crlx.core.test.TestClass.main(TestClass.java:104)
Caused by: org.hibernate.exception.DataException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.springframework.orm.hibernate3.HibernateTemplate$35.doInHibernate(HibernateTemplate.java:991)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
... 3 more
Caused by: org.postgresql.util.PSQLException: Für den Parameter 1 wurde kein Wert angegeben.
at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:146)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:182)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 10 more
Name and version of the database you are using:
PostgreSQL 8.2.4
The generated SQL (show_sql=true):
Hibernate: select this_.guid as guid0_0_, this_.status as status6_0_, this_.creationtime as creation1_7_0_, this_.lastchange as lastchange7_0_, this_.descr as descr12_0_ from keyword this_ where this_.guid in (?)
Debug level Hibernate log excerpt:
16:14:10,406 DEBUG SQL:401 - select this_.guid as guid0_0_, this_.status as status6_0_, this_.creationtime as creation1_7_0_, this_.lastchange as lastchange7_0_, this_.descr as descr12_0_ from keyword this_ where this_.guid in (?)
Hibernate: select this_.guid as guid0_0_, this_.status as status6_0_, this_.creationtime as creation1_7_0_, this_.lastchange as lastchange7_0_, this_.descr as descr12_0_ from keyword this_ where this_.guid in (?)
16:14:10,468 DEBUG AbstractBatcher:374 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
16:14:10,484 DEBUG JDBCExceptionReporter:69 - could not execute query [select this_.guid as guid0_0_, this_.status as status6_0_, this_.creationtime as creation1_7_0_, this_.lastchange as lastchange7_0_, this_.descr as descr12_0_ from keyword this_ where this_.guid in (?)]
org.postgresql.util.PSQLException: Für den Parameter 1 wurde kein Wert angegeben.
at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:146)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:182)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:351)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:255)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
at org.springframework.orm.hibernate3.HibernateTemplate$35.doInHibernate(HibernateTemplate.java:991)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:373)
at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:981)
at org.springframework.orm.hibernate3.HibernateTemplate.findByCriteria(HibernateTemplate.java:974)
at org.crlx.core.test.TestClass.main(TestClass.java:104)
16:14:10,531 WARN JDBCExceptionReporter:77 - SQL Error: 0, SQLState: 22023
16:14:10,531 ERROR JDBCExceptionReporter:78 - Für den Parameter 1 wurde kein Wert angegeben.
|