Hibernate NoSuchElementException

This was a really strange error and I didn’t have a clue when I looked at it for the first time. All other hibernate calls worked fine excepted this one. So I tried to execute the query without any where clause and it worked without any issues. It turned out to be an issue with unmatched parentheses. I added the extra parentheses and it worked fine. There is no way you can tell this by looking at the stack trace.

java.util.NoSuchElementException
 at java.util.LinkedList.remove(LinkedList.java:788)
 at java.util.LinkedList.removeLast(LinkedList.java:144)
 at org.hibernate.jdbc.util.BasicFormatterImpl$FormatProcess.closeParen(BasicFormatterImpl.java:337)
 at org.hibernate.jdbc.util.BasicFormatterImpl$FormatProcess.perform(BasicFormatterImpl.java:159)
 at org.hibernate.jdbc.util.BasicFormatterImpl.format(BasicFormatterImpl.java:91)
 at org.hibernate.jdbc.util.SQLStatementLogger.logStatement(SQLStatementLogger.java:109)
 at org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:444)
 at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:511)
 at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:452)
 at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
 at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1577)
 at org.hibernate.loader.Loader.doQuery(Loader.java:696)
 at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
 at org.hibernate.loader.Loader.doList(Loader.java:2232)
 at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
 at org.hibernate.loader.Loader.list(Loader.java:2124)
 at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
 at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
 at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
 at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
 at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
 at com.jReward.dao.member.attribute.impl.MemberAttributeDaoImpl.getUnexpiredAttribs(MemberAttributeDaoImpl.java:64)
 at com.jReward.dao.member.attribute.impl.MemberAttributeDaoImpl.hasActiveAttribute(MemberAttributeDaoImpl.java:44)
 at com.jReward.dao.member.attribute.impl.MemberAttributeDaoImpl.createIfNotPresent(MemberAttributeDaoImpl.java:70)
 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:310)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
 at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 at $Proxy53.createIfNotPresent(Unknown Source)
..



Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: