java - could not extract ResultSet in Hibernate Criteria -


i got exception after appropriate result criteria.uniqueresult() object quote. purpose query - random result table 'quotes' db oracle

org.hibernate.exception.sqlgrammarexception: not extract resultset @ org.hibernate.exception.internal.sqlexceptiontypedelegate.convert(sqlexceptiontypedelegate.java:80) @ org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter.java:49) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:126) @ org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper.java:112) @ org.hibernate.engine.jdbc.internal.resultsetreturnimpl.extract(resultsetreturnimpl.java:91) @ org.hibernate.loader.loader.getresultset(loader.java:2065) @ org.hibernate.loader.loader.executequerystatement(loader.java:1862) @ org.hibernate.loader.loader.executequerystatement(loader.java:1838) @ org.hibernate.loader.loader.doquery(loader.java:909) @ org.hibernate.loader.loader.doqueryandinitializenonlazycollections(loader.java:354) @ org.hibernate.loader.loader.dolist(loader.java:2553) @ org.hibernate.loader.loader.dolist(loader.java:2539) @ org.hibernate.loader.loader.listignorequerycache(loader.java:2369) @ org.hibernate.loader.loader.list(loader.java:2364) @ org.hibernate.loader.criteria.criterialoader.list(criterialoader.java:126) @ org.hibernate.internal.sessionimpl.list(sessionimpl.java:1682) @ org.hibernate.internal.criteriaimpl.list(criteriaimpl.java:380) @ org.hibernate.internal.criteriaimpl.uniqueresult(criteriaimpl.java:402) @ ua.com.goit.gojava7.kikstarter.dao.database.quotedaodbimpl.getrandomquote(quotedaodbimpl.java:42) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:302) @ org.springframework.aop.framework.reflectivemethodinvocation.invokejoinpoint(reflectivemethodinvocation.java:190) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:157) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:99) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:281) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:96) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:179) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:207) @ com.sun.proxy.$proxy48.getrandomquote(unknown source) @ ua.com.goit.gojava7.kikstarter.controller.servlet.selectoincategories.doget(selectoincategories.java:43) @ javax.servlet.http.httpservlet.service(httpservlet.java:621) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:502) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:953) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:408) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1023) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) @ org.apache.tomcat.util.net.jioendpoint$socketprocessor.run(jioendpoint.java:312) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) @ java.lang.thread.run(thread.java:722)

class quotedaodbimpl

@repository public class quotedaodbimpl implements quotedao {      private static final string select_random_quote = "select * (select * quotes order dbms_random.value) rownum = 1";      @autowired     private sessionfactory sessionfactory;      @transactional     @override     public quote getrandomquote() {         session session = sessionfactory.getcurrentsession();          criteria criteria = session.createcriteria(quote.class);         criteria.add(restrictions.sqlrestriction(select_random_quote));         criteria.setmaxresults(1);          quote quote = (quote) criteria.uniqueresult();         session.close();          return quote;     } } 

class selectoincategories

@webservlet("/categories") public class selectoincategories extends httpservlet {     /**     *      */     private static final long serialversionuid = 1l;      @autowired     private quotedao quotedao;      @autowired     private categorydao categorydao;      public void init() throws servletexception {          springbeanautowiringsupport.processinjectionbasedonservletcontext(this, getservletcontext());      }      protected void doget(httpservletrequest request, httpservletresponse response)         throws servletexception, ioexception {          quote quote = quotedao.getrandomquote();         list<category> categories = categorydao.getall();          request.setattribute("content", quote.getcontent());         request.setattribute("author", quote.getauthor());         request.setattribute("categories", categories);         request.getrequestdispatcher("web-inf/jsp/categories.jsp").forward(request, response);      } } 

class quote

@entity @table(name = "qoutes") public class quote {      @id     @sequencegenerator(name = "seq_gen", sequencename = "seq_id", allocationsize = 10)     @generatedvalue(strategy = generationtype.sequence, generator = "seq_gen")     private int id;      @column(name = "content")     private string content;      @column(name = "author")     private string author;      public quote() {     }      public quote(string content, string author) {         this.content = content;         this.author = author;     }      public int getid() {         return id;     }      public string getcontent() {         return content;     }      public string getauthor() {         return author;     }      public void setid(int id) {         this.id = id;     }      public void setcontent(string quotecontent) {         this.content = quotecontent;     }      public void setauthor(string quoteauthor) {         this.author = quoteauthor;     }      public string tostring() {         return "id: " + id + "; content: " + content + "; author: " + author;     }  } 

table quotes

create table quotes ( id integer not null, content varchar2(500) not null, author varchar2(100) not null ); 

modify try

 private static final string select_random_quote =      "select id, content, author      (select * quotes order dbms_random.value) quotes  rownum = 1"; 

Comments