Java EE Web应用程序测试JPA EJB3(Java EE web application Tests JPA EJB3)
我在JSF Managed bean中使用EJB3 DAOFacade从数据库中提取数据。 它适用于服务器的首次启动,但之后它继续打印此消息错误,我不明白。 有人可以告诉我发生了什么事吗?
WARNING: EJB5184:A system exception occurred during an invocation on EJB AirportFacade, method: public java.util.List com.procc.flams.dao.AbstractFacade.findAll() WARNING: javax.ejb.EJBException at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5215) at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5113) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4901) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89) at com.sun.proxy.$Proxy173.findAll(Unknown Source) at com.procc.flams.backing.AirportController.getItems(AirportController.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at javax.el.BeanELResolver.getValue(BeanELResolver.java:363) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) at com.sun.el.parser.AstValue.getValue(AstValue.java:138) at com.sun.el.parser.AstValue.getValue(AstValue.java:183) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) at javax.faces.component.UIData.getValue(UIData.java:731) at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:786) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.sun.faces.facelets.util.DevTools.writeAttributes(DevTools.java:375) at com.sun.faces.facelets.util.DevTools.writeStart(DevTools.java:424) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:245) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:264) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:264) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:264) at com.sun.faces.facelets.util.DevTools.debugHtml(DevTools.java:128) at com.sun.faces.renderkit.RenderKitUtils.renderHtmlErrorPage(RenderKitUtils.java:1162) at com.sun.faces.context.ExceptionHandlerImpl.throwIt(ExceptionHandlerImpl.java:276) at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:142) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.postgresql.core.v3.QueryExecutorImpl$1], because it has not yet been started, or was already stopped at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1401) at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359) at org.postgresql.core.v3.QueryExecutorImpl.sendQueryPreamble(QueryExecutorImpl.java:432) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:252) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) at com.sun.proxy.$Proxy180.executeQuery(Unknown Source) at org.hibernate.loader.Loader.getResultSet(Loader.java:2031) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1832) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1811) at org.hibernate.loader.Loader.doQuery(Loader.java:899) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) at org.hibernate.loader.Loader.doList(Loader.java:2516) at org.hibernate.loader.Loader.doList(Loader.java:2502) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332) at org.hibernate.loader.Loader.list(Loader.java:2327) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490) 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:1247) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:264) at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3.getResultList(CriteriaQueryCompiler.java:254) at com.procc.flams.dao.AbstractFacade.findAll(AbstractFacade.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124) at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388) at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370) at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214) ... 59 more
在JSF页面中:
<p:panel header="Airports list"> <p:dataTable value="#{airportController.items}" var="item"> <p:column> <f:facet name="header">ID</f:facet> <h:outputText value="#{item.airportId}"/> </p:column>
生成错误的JSF代码:
public List<Airport> getItems() { if(items==null){ items = airportFacade.findAll(); } return items; }
和持久性代码(我使用Hibernate 4.1作为JPA Provider):
public List<T> findAll() { javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); cq.select(cq.from(entityClass)); return getEntityManager().createQuery(cq).getResultList(); }
I am using an EJB3 DAOFacade inside a JSF Managed bean to pull data from database. It worked for the first launch of the server but after that it keeps printing this message error which i don't understand. Could anybody please tell me what is going on ?
WARNING: EJB5184:A system exception occurred during an invocation on EJB AirportFacade, method: public java.util.List com.procc.flams.dao.AbstractFacade.findAll() WARNING: javax.ejb.EJBException at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5215) at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5113) at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4901) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045) at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89) at com.sun.proxy.$Proxy173.findAll(Unknown Source) at com.procc.flams.backing.AirportController.getItems(AirportController.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at javax.el.BeanELResolver.getValue(BeanELResolver.java:363) at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176) at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) at com.sun.el.parser.AstValue.getValue(AstValue.java:138) at com.sun.el.parser.AstValue.getValue(AstValue.java:183) at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224) at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) at javax.faces.component.UIData.getValue(UIData.java:731) at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:786) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.sun.faces.facelets.util.DevTools.writeAttributes(DevTools.java:375) at com.sun.faces.facelets.util.DevTools.writeStart(DevTools.java:424) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:245) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:264) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:264) at com.sun.faces.facelets.util.DevTools.writeComponent(DevTools.java:264) at com.sun.faces.facelets.util.DevTools.debugHtml(DevTools.java:128) at com.sun.faces.renderkit.RenderKitUtils.renderHtmlErrorPage(RenderKitUtils.java:1162) at com.sun.faces.context.ExceptionHandlerImpl.throwIt(ExceptionHandlerImpl.java:276) at com.sun.faces.context.ExceptionHandlerImpl.handle(ExceptionHandlerImpl.java:142) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:722) Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.postgresql.core.v3.QueryExecutorImpl$1], because it has not yet been started, or was already stopped at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1401) at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359) at org.postgresql.core.v3.QueryExecutorImpl.sendQueryPreamble(QueryExecutorImpl.java:432) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:252) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:273) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122) at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) at com.sun.proxy.$Proxy180.executeQuery(Unknown Source) at org.hibernate.loader.Loader.getResultSet(Loader.java:2031) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1832) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1811) at org.hibernate.loader.Loader.doQuery(Loader.java:899) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341) at org.hibernate.loader.Loader.doList(Loader.java:2516) at org.hibernate.loader.Loader.doList(Loader.java:2502) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332) at org.hibernate.loader.Loader.list(Loader.java:2327) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490) 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:1247) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:264) at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3.getResultList(CriteriaQueryCompiler.java:254) at com.procc.flams.dao.AbstractFacade.findAll(AbstractFacade.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124) at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388) at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370) at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214) ... 59 more
in JSF page:
<p:panel header="Airports list"> <p:dataTable value="#{airportController.items}" var="item"> <p:column> <f:facet name="header">ID</f:facet> <h:outputText value="#{item.airportId}"/> </p:column>
JSF code which generates the error:
public List<Airport> getItems() { if(items==null){ items = airportFacade.findAll(); } return items; }
and Persistence code (I am using Hibernate 4.1 as JPA Provider):
public List<T> findAll() { javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery(); cq.select(cq.from(entityClass)); return getEntityManager().createQuery(cq).getResultList(); }
原文:https://stackoverflow.com/questions/16678871
最满意答案
编辑:在这里添加小提琴: http : //jsfiddle.net/jnS3H/12/与您的代码和修复。
要做间隔计时器,你可以这样做:
//create a function to handle the auto rotate function autoRotate() { //code here for what happens every n seconds } //create a function that holds the interval to do an auto rotate push function rotate(){ var startRotate = setInterval(function(){ //Start the autorotate on load to rotate every 2 seconds. autoRotate(); }, 2000); } $('.rightarrow, .leftarrow').click(function(){ clearInterval(startRotate); //Stops the auto-animation clearTimeout(startAgain); //Stops the starting again - incase you click again, it resets the timeout //write some code here to do something when you click on the right arrow var startAgain = setTimeout(function(){ //Then create a timeout to start rotating again after you click rotate(); }, 2000); }); $(document).load(function(){ rotate(); });
这是非常松散的代码,当然,你必须填写空白并测试它,但我相信校长是正确的。
EDIT: Added fiddle here: http://jsfiddle.net/jnS3H/12/ with your code and a fix.
To do an interval timer, you can do something like this:
//create a function to handle the auto rotate function autoRotate() { //code here for what happens every n seconds } //create a function that holds the interval to do an auto rotate push function rotate(){ var startRotate = setInterval(function(){ //Start the autorotate on load to rotate every 2 seconds. autoRotate(); }, 2000); } $('.rightarrow, .leftarrow').click(function(){ clearInterval(startRotate); //Stops the auto-animation clearTimeout(startAgain); //Stops the starting again - incase you click again, it resets the timeout //write some code here to do something when you click on the right arrow var startAgain = setTimeout(function(){ //Then create a timeout to start rotating again after you click rotate(); }, 2000); }); $(document).load(function(){ rotate(); });
This is very loose code of course, you will have to fill in the blanks and test it, but I believe the principal is correct.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
android:versionCode="28" 你以前的versionCode是28.你应该增加1到29。 android:versionCode="29" 大概以前的应用程序版本是1到28.通过使用versionCode 3发布,您与以前版本的应用程序已经与此版本代码一起发布了冲突。 android:versionCode="28" Your previous versionCode was 28. You should increment it by 1 to 29. android:versi ...
-
所以,我看到这样: 根据您所提供的文章,使用ant进行此任务(目标?)。 解析清单(解析XML) 获取旧版本表单,并从repo增加/获取版本 在清单中存储新版本 构建Android应用程序。 但是,当我部署或分发应用程序时,我通常会通过基于Tag修订的值填充此字段。 So, I see it like this: Depending on article that you present, use ant for this tasks (targets?). parse Manifest (parse XM ...
-
尝试这个: HTML:123找到了一个自定义的build.gradle文件,可以在这里找到技巧: link Found a custom build.gradle file that does the trick here: link编辑:在这里添加小提琴: http : //jsfiddle.net/jnS3H/12/与您的代码和修复。 要做间隔计时器,你可以这样做: //create a function to handle the auto rotate function autoRotate() { //code here for what happens every n seconds } //create a function that holds the interval to do an auto rotate ...
标签中自动包含版本号(Auto-Include Version # in Label)[2021-06-13]
如何使用汇编版本? 如果你让它自动uprev,这可以节省你一些时间。 var appVersion = Assembly.GetExecutingAssembly().GetName().Version; versionLabel.Text = String.Format("v{0}", appVersion); 这将基于AssemblyInfo的版本。 要详细说明我的意思,如果你看一下AssemblyInfo.cs ,你会看到如下内容: // Version information for an ass ...老实说,这似乎是矫枉过正做代码中的所有这些。 我建议创建一个布局文件,并多次膨胀。 使appLayout具有垂直方向的LinearLayout,它将如此简单: for(int x = 1; x <= 15; x++){ View view = LayoutInflater.from(this).inflate(R.layout.some_layout, appLayout, false); // Configure the items inside the view Button butto ...OpenERP 7:单击保存后如何触发自动版本增加功能(OpenERP 7 : How to trigger a auto version increase function after click save)[2022-06-19]
您需要覆盖write方法。 def write(self, cr, uid, ids, vals, context=None): res = super(your_model, self).write(cr, uid, ids, vals, context) self._increment_version(cr, uid, ids) return res def _increment_version(self, cr, uid, ids): for record in se ...相关文章
更多- 《Java开发课程:JSP视频教程》(JSP WEB J2EE)共20集更新完毕!
- 精通EJB3.0
- JAVA WEB
- 《EJB 3.0从入门到精通》扫描版[PDF]
- EJB3.0 视频教程-尚学堂视频教程
- Hibernate在Web应用程序中使用示例
- Gradle构建Java Web应用程序并在Tomcat上运行
- Java web面试题(一)
- JAVA开源项目[转]
- JAVA开源项目[转]
最新问答
更多- 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
- linux的常用命令干什么用的
- 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
- 如何交换返回集中的行?(How to swap rows in a return set?)
- 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
- 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
- Java中的不可变类(Immutable class in Java)
- WordPress发布查询(WordPress post query)
- 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
- 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
- GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
- 绑定属性设置器未被调用(Bound Property Setter not getting Called)
- linux ubuntu14.04版没有那个文件或目录
- 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
- 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
- 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
- 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
- ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
- linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
- Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
- 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
- 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
- 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
- Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
- 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
- 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
- 如何按部门显示报告(How to display a report by Department wise)
- Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
- Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
- WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)