2
在@Lob
字段中執行搜索查詢時,我收到了一個奇怪的行爲。在@Lob字段中搜索IndexOutOfBound
我在JPA2中使用HSQLDB和Hibernate。
查詢結果是:@NamedQuery(name = "URL.findByPathAndDomain", query = "select u from URL u where u.path = :path and u.domain.domain = :domain")
(path
順便說一下是@lob字段)。
我實現的方法DAO這樣的:
public URL findByPathAndDomain(String path, String domain) {
URL url = null;
TypedQuery<URL> query = em().createNamedQuery("URL.findByPathAndDomain", URL.class);
query.setParameter("path", path);
query.setParameter("domain", domain);
try {
url = query.getSingleResult();
} catch (NoResultException e) {
logger.error(e.getMessage());
}
return url;
}
而且我得到這個異常:
Caused by: org.hibernate.exception.GenericJDBCException: java.lang.NullPointerException java.lang.NullPointerException
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy45.executeQuery(Unknown Source)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1897)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1698)
at org.hibernate.loader.Loader.doQuery(Loader.java:832)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293)
at org.hibernate.loader.Loader.doList(Loader.java:2382)
at org.hibernate.loader.Loader.doList(Loader.java:2368)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2198)
at org.hibernate.loader.Loader.list(Loader.java:2193)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1248)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:285)
... 10 more
如果我刪除@Lob
註釋,一切順利。 這是HSQLDB錯誤,Hibernate錯誤還是什麼?
編輯:我改變PU,而不是使用HSQLDB MySQL和它就像一個老闆...
嗯,有趣的是,最好的方法是什麼? – caarlos0