-
1. Re: Query task with variables
tvictor May 19, 2010 1:18 PM (in response to tvictor)I tried another query
entityManager.createQuery("SELECT task.execution.variables from org.jbpm.api.task.Task task where index(task.execution.variables[0])='invoiceId' and task.execution.variables[0].l=23").getResultList()
Which gives me no results. That is expected because there is no varialbe with value 23
But when I changed the value to 16 it is giving me the following error. The value 16 is actually existing in the database. Can anyone help to correct this query?
Thanks
Thomas
12:15:51,422 WARN [JDBCExceptionReporter] SQL Error: 245, SQLState: S000112:15:51,422 ERROR [JDBCExceptionReporter] Conversion failed when converting the varchar value 'invoiceId' to data type int.12:15:51,422 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query12:15:51,422 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)12:15:51,422 ERROR [STDERR] at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:76)12:15:51,422 ERROR [STDERR] at com.imagitek.prodagioap.workflow.TaskService.getGroupTasks(TaskService.java:72)12:15:51,422 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor601.invoke(Unknown Source)12:15:51,422 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)12:15:51,422 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)12:15:51,422 ERROR [STDERR] at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)12:15:51,422 ERROR [STDERR] at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)12:15:51,422 ERROR [STDERR] at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:77)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)12:15:51,422 ERROR [STDERR] at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:51)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)12:15:51,422 ERROR [STDERR] at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)12:15:51,422 ERROR [STDERR] at org.jboss.seam.util.Work.workInTransaction(Work.java:61)12:15:51,422 ERROR [STDERR] at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)12:15:51,422 ERROR [STDERR] at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)12:15:51,422 ERROR [STDERR] at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)12:15:51,422 ERROR [STDERR] at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)12:15:51,422 ERROR [STDERR] at com.imagitek.prodagioap.workflow.invoice.InvoiceTaskService_$_javassist_seam_13.getGroupTasks(InvoiceTaskService_$_javassist_seam_13.java)12:15:51,422 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor600.invoke(Unknown Source)12:15:51,422 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)12:15:51,422 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)12:15:51,422 ERROR [STDERR] at javax.el.BeanELResolver.getValue(BeanELResolver.java:261)12:15:51,422 ERROR [STDERR] at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:143)12:15:51,422 ERROR [STDERR] at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)12:15:51,422 ERROR [STDERR] at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)12:15:51,422 ERROR [STDERR] at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)12:15:51,422 ERROR [STDERR] at org.jboss.el.parser.AstEmpty.getValue(AstEmpty.java:29)12:15:51,422 ERROR [STDERR] at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)12:15:51,422 ERROR [STDERR] at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)12:15:51,422 ERROR [STDERR] at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:390)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:271)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)12:15:51,422 ERROR [STDERR] at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:200)12:15:51,422 ERROR [STDERR] at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:195)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)12:15:51,422 ERROR [STDERR] at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)12:15:51,422 ERROR [STDERR] at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)12:15:51,422 ERROR [STDERR] at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)12:15:51,422 ERROR [STDERR] at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)12:15:51,422 ERROR [STDERR] at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)12:15:51,422 ERROR [STDERR] at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)12:15:51,422 ERROR [STDERR] at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)12:15:51,422 ERROR [STDERR] at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)12:15:51,422 ERROR [STDERR] at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)12:15:51,422 ERROR [STDERR] at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)12:15:51,422 ERROR [STDERR] at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)12:15:51,422 ERROR [STDERR] at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)12:15:51,422 ERROR [STDERR] at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)12:15:51,422 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)12:15:51,422 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)12:15:51,422 ERROR [STDERR] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)12:15:51,422 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)12:15:51,422 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)12:15:51,422 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)12:15:51,422 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)12:15:51,422 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)12:15:51,422 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)12:15:51,422 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)12:15:51,422 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)12:15:51,422 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)12:15:51,422 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)12:15:51,422 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)12:15:51,422 ERROR [STDERR] Caused by: org.hibernate.exception.SQLGrammarException: could not execute query12:15:51,422 ERROR [STDERR] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)12:15:51,422 ERROR [STDERR] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)12:15:51,422 ERROR [STDERR] at org.hibernate.loader.Loader.doList(Loader.java:2235)12:15:51,422 ERROR [STDERR] at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)12:15:51,422 ERROR [STDERR] at org.hibernate.loader.Loader.list(Loader.java:2124)12:15:51,422 ERROR [STDERR] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)12:15:51,422 ERROR [STDERR] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)12:15:51,422 ERROR [STDERR] at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)12:15:51,422 ERROR [STDERR] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)12:15:51,422 ERROR [STDERR] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)12:15:51,422 ERROR [STDERR] at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)12:15:51,422 ERROR [STDERR] ... 100 more12:15:51,422 ERROR [STDERR] Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting the varchar value 'invoiceId' to data type int.12:15:51,422 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:196)12:15:51,422 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerResultSet$FetchBuffer.nextRow(SQLServerResultSet.java:4700)12:15:51,422 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerResultSet.fetchBufferNext(SQLServerResultSet.java:1683)12:15:51,422 ERROR [STDERR] at com.microsoft.sqlserver.jdbc.SQLServerResultSet.next(SQLServerResultSet.java:956)12:15:51,422 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedResultSet.next(WrappedResultSet.java:1196)12:15:51,422 ERROR [STDERR] at org.hibernate.loader.Loader.doQuery(Loader.java:720)12:15:51,422 ERROR [STDERR] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)12:15:51,422 ERROR [STDERR] at org.hibernate.loader.Loader.doList(Loader.java:2232)12:15:51,422 ERROR [STDERR] ... 108 more -
2. Re: Query task with variables
rebody May 20, 2010 4:16 AM (in response to tvictor)Hi Thomas,
First, org.jbpm.api.task.Task is an interface, the implemented class is org.jbpm.pvm.internal.task.TaskImpl.
Second, at this moment, jbpm4 didn't support JPA. So I am afraid you cannot do such query in entityManager.
-
3. Re: Query task with variables
tvictor May 21, 2010 2:17 PM (in response to rebody)Thank you very much for your reply.
I do not think it has anything to do with JPA. I tried the options you suggested but still did not work.
But now I changed my query a little but I am joining the task, with variables explicitly then it works.
-
4. Re: Query task with variables
rebody May 21, 2010 9:49 PM (in response to tvictor)Hi Thomas,
Interesting. Do you mean that we could query the domain object of jBPM 4 from JPA entityManager? Could you show me the final query string content? I want to have a try. Thank you very much.
-
5. Re: Query task with variables
tvictor May 24, 2010 10:40 AM (in response to rebody)Hi HuiSheng Xu,
Thank you very much for replying to my post.
The way in which it works is described below.
I added the jbpm mappings to my persistence.xml. Please see the configuration below. So that my persistence unit contains the jbpm tables also. So I can use jbpm objects along with my domain objects in JPA.
The query is given below
entityManager.createQuery("SELECT new com.imagitek.prodagioap.workflow.invoice.InvoiceTask(task, invoice) from org.jbpm.api.task.Task task, org.jbpm.pvm.internal.type.Variable var, com.imagitek.prodagioap.entity.ImInvoice invoice where var.execution=task.execution and invoice.id=var.l").getResultList();
This works because I know my variable will be a long data type.
? Right now I have a separate jbpm.hibernate.cfg.xml which is supplied by jbpm4. I am using this configuration also. Ultimately I want to use only the JPA configuration for everything. I want to get rid of the jbpm.hibernate.cfg.xml file. While creating the process engine I was able to supply hibernateSessionFactory which is provided by jpa/seam to the process engine. Then I was able to get rid of the jbpm.hibernate.cfg.xml. but the problem was that no data was persisted to the database. But all the rules, events etc were getting fired. I assume I am missing some transaction related stuff. Can please tell me what are the things I need to do to persist the data.
Thanks & Regards
Thomas Victor
<persistence-unit name="prodagioAP" transaction-type="JTA"><provider>org.hibernate.ejb.HibernatePersistence</provider><jta-data-source>java:/prodagioAPDatasource</jta-data-source><mapping-file>jbpm.repository.hbm.xml</mapping-file><mapping-file>jbpm.execution.hbm.xml</mapping-file><mapping-file>jbpm.history.hbm.xml</mapping-file><mapping-file>jbpm.task.hbm.xml</mapping-file><!-- <mapping-file>jbpm.identity.hbm.xml</mapping-file>--><properties><property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/><property name="hibernate.hbm2ddl.auto" value="validate"/><property name="hibernate.show_sql" value="false"/><property name="hibernate.format_sql" value="true"/><property name="jboss.entity.manager.factory.jndi.name" value="java:/prodagioAPEntityManagerFactory"/><property name="hibernate.search.default.indexBase" value="/prodagio_indexs"/><property name="hibernate.ejb.event.post-insert" value="org.hibernate.search.event.FullTextIndexEventListener"/><property name="hibernate.ejb.event.post-update" value="org.hibernate.search.event.FullTextIndexEventListener"/><property name="hibernate.ejb.event.post-delete" value="org.hibernate.search.event.FullTextIndexEventListener"/></properties></persistence-unit> -
6. Re: Query task with variables
tvictor May 25, 2010 10:42 AM (in response to tvictor)Hi,
I figured it out. I commented out the hibernate-configuration and hibernate-session-factory from the file jbpm.tx.jta.cfg.xml.
While creating the process engine I use the following code to get the session factory from entitymanager. It works fine.
Session hibernateSession = (Session)entityManager.getDelegate();SessionFactory sFactory = hibernateSession.getSessionFactory();jbpmConfiguration.setHibernateSessionFactory(sFactory);processEngine = jbpmConfiguration.buildProcessEngine();Each time when I do some some operation that needs database persistence like start a workflow, signal a task etc. I need to add the entitymanager to the transaction. Then I am able to persist the data and it works.
entityManager.joinTransaction();
pi = super.startWorkflow("InvoiceProcessing", variables, workflowKey);
? Right now I extracted the hbpm.jar, then modified the bpm.tx.jta.cfg.xml then jarred it back. Is there any way to add the configuration on the jbpm.cfg.xml. I mean any way to leave the jar file as it is and do configurations out side?
-
7. Re: Query task with variables
swiderski.maciej May 25, 2010 12:31 PM (in response to tvictor)Thomas Victor wrote:
? Right now I extracted the hbpm.jar, then modified the bpm.tx.jta.cfg.xml then jarred it back. Is there any way to add the configuration on the jbpm.cfg.xml. I mean any way to leave the jar file as it is and do configurations out side?
Sure, you can supply your configuration prior to building your process engine.
Configuration configuration = new Configurtion(); configuration.setFile("path to your custom config"); ProcessEngine processEngine = configuration.buildProcessEngine();
setFile is only of of the available options, you can use class path resource, input stream, etc. Please refer to JavaDocs for more details.
HTH
Maciej
-
8. Re: Query task with variables
tvictor May 25, 2010 12:35 PM (in response to swiderski.maciej)Thank you very much for your reply. I will try that.
-
9. Re: Query task with variables
swiderski.maciej May 25, 2010 4:12 PM (in response to swiderski.maciej)Maciej Swiderski wrote:
setFile is only of of the available options, you can use class path resource, input stream, etc. Please refer to JavaDocs for more details.
It suppose to be:
setFile is NOT the only one of available options....
Sorry for this typo