Hi,
I'm using Hibernate 3.2. When I run code like the following
log.info("setting criteria license number:" + licenseNumber); Criteria criteria = session.createCriteria(InterlockExtract.class); criteria.add(Restrictions.eq("licenseNumber", licenseNumber.trim())); result = (InterlockExtract) criteria.uniqueResult();
The criteria.uniqueResult line throws the below error. I was under the impression that if no results are to be returned, it should simply return null without an exception being thrown. Could someone explain what is going on and how to configure hibernate so that it will simply return null if there are no results to return?
Thanks, - Dave
java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:558) at org.hibernate.type.CharacterType.get(CharacterType.java:29) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163) at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:81) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2101) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1380) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1308) at org.hibernate.loader.Loader.getRow(Loader.java:1206) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580) at org.hibernate.loader.Loader.doQuery(Loader.java:701) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236) at org.hibernate.loader.Loader.doList(Loader.java:2213) 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.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:305) at myco.dor.online.interlock.service.ejb.InterlockServiceBean.getInterlockExtract(InterlockServiceBean.java:1050) at _ejb.InterlockServiceBean.InterlockServiceBean__EJB$Remote.getInterlockExtract(InterlockServiceBean__EJB.java:482) at _ejb.myco.dor.online.interlock.service.ejb.InterlockServiceRemote__HessianSkel._execute(InterlockServiceRemote__HessianSkel.java:130) at com.caucho.ejb.hessian.HessianSkeleton._service(HessianSkeleton.java:126) at com.caucho.ejb.EJBServlet.service(EJBServlet.java:224) at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:106) at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:188) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:178) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:229) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268) at com.caucho.server.port.TcpConnection.run(TcpConnection.java:389) at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:507) at com.caucho.util.ThreadPool.run(ThreadPool.java:433) at java.lang.Thread.run(Thread.java:613)
|