[Persistence, JBoss/CMP, Hibernate, Database] - How to write a finder query that takes a collection paramete
by jwiegley
I have an older BES codebase which I'm trying to port to JBoss. Since that codebase targets EJB CMP 1.x -- and has no concept of local interfaces, etc. -- the best approach so far seems to be to get JBoss to deploy those 1.x beans as they are.
However, BES allows for finder queries like this:
<finder>
| <method-signature>findByResourceList( String[] asResourceIDList )</method-signature>
| <where-clause> MyResourceID in ( :asResourceIDList ) </where-clause>
| </finder>
I thought that in my jbosscmp-jdbc.xml file, I could just write this to emulate the above:
<query>
| <query-method>
| <method-name>findByResourceList</method-name>
| <method-params>
| <method-param>java.lang.String[]</method-param>
| </method-params>
| </query-method>
| <declared-sql>
| <where>ID in ({0})</where>
| </declared-sql>
| </query>
However, while this builds, deploys and executes without a hitch, it does not find anything. I'm not sure what substitution syntax {0} results in in this case.
Anyway, can anyone offer a clue as to how to pass a collection as a finder parameter, and then query my database to check for any entries whose ID matches any member of that collection?
Thanks,
John
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024763#4024763
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024763
17Â years, 10Â months
[JBoss jBPM] - Re: Stateless Process Engine executor threading issues
by jorgemoralespou_2
Sure I can, Ronald.
For what we need, as Tom said, we really didn't want to persist our process definition, or the execution of the process instances, or anything at all, so while I was working out the JUnit test you asked me for, and trying to figure out how to make my engine work, I did what you asked me for, create an inline String with my processdefinition, and feed it to my process engine. Also, because I was working outside an AS, I look at the examples, and saw that there is a way to create a ProcessInstance without a JBPMContext. So I did this, and voila, it worked without persistance at all, so I modified my engine, and instead of loading process definitions from database, I load them from a memory repository, through an MBean. I create my repository when I deploy the jboss .sar that holds the definition, implementing action handlers, and web service facade.
We have done lots of stuff for it to work inside JBossAS.
Now it runs as we expected. Until we need real persitence for processes, will keep on this. Probably we will keep our previous implementation for something as statefull processes, we will need in the future.
This is kinda the method we use now.
| public Object executeProcessInstance(String processName, Map request) throws Exception{
| // Get process definition
| ProcessDefinition processDefiniton = myMBean.findLatestProcessDefinition(processName);
| if (processDefiniton == null) {
| throw new Exception("Process definition not found");
| }
|
| ProcessInstance instance = new ProcessInstance(processDefiniton);
| instance.getContextInstance().setTransientVariable("REQUEST", request);
|
| // Execute process
| do{
| instance.getRootToken().signal();
| }while (!instance.getRootToken().hasEnded());
|
| // Check that execution is on a end state. if not, throw exception
| if (!EndState.class.isAssignableFrom(instance.getRootToken()
| .getNode().getClass())) {
| throw new Exception("Process finished not in an End Node");
| }
|
| Object response = instance.getContextInstance().getTransientVariable("RESPONSE");
| return response;
| }
|
It would be great if we could use the database to store our process definitions, and load the process definition from there, but as I see, for now it's hibernate for all or nothing. :-(
Also, we did have to keep signaling our home made action handlers. Probably we have done something wrong, but that belongs to other post, I think. ;-)
Thank you very much for both of you.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024756#4024756
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024756
17Â years, 10Â months
[Beginners Corner] - Re: Auth How to
by PeterJ
OK, now I see what you mean. The DataBaseServerLoginModule is written incorrectly. It expects you to be able to write a select statement that returns the unencrypted password. If you have a password that is encrypted using one-way encryption, the DataBaseServerLoginModule will not be able to use it because it does not support any way of dealing with the password. What is needed is a new login module that allows the following entry (if using MySQL and ecrypting the password with the SHA1() function):
<module-option name = "principalsQuery">SELECT loginId FROM User WHERE loginId=? and password=sha1(?)</module-option>
This login module would accept the loginId an password is the select statement returns a single result.
An alternative would be to add a new option to the existing login module, something like:
<module-option name = "passwordQuery">SELECT sha1(?)
The existing login module could then use this query to encode the password before testing it against the password returned by the current query (which returns the value of the password column).
On further thought, looking at the code, there does appear to be support for this. I see references to a callback method related to passwords (UsernamePasswordLoginModule.createPasswordHash), and a method to truend a hashed password (DabaseServerLoginModule). Though it looks as if you have to write your own subclass of DabaseServerLoginModule. Hmm, a subclass that supports my 'passwordQuery' option might be a good idea.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024751#4024751
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024751
17Â years, 10Â months
[JBoss Seam] - Re: Setting up an ajax4jsf + trinidad project
by dustismo
You were right, I didn't have the impl jar in there. So now everything starts with no exceptions but I'm not sure its working.
I set up the project using seam-gen (so I assume the jars are automatically added to the jar manifest by the build script).
<target name="ear" description="Build the EAR">
| <copy todir="${ear.dir}">
| <fileset dir="${basedir}/resources">
| <include name="*jpdl.xml" />
| <include name="hibernate.cfg.xml" />
| <include name="jbpm.cfg.xml" />
| <include name="security.drl" />
| </fileset>
| <fileset dir="${lib.dir}">
| <include name="jboss-seam.jar" />
| <include name="jbpm*.jar" />
| <include name="el-*.jar" />
| <include name="drools-*.jar"/>
| <include name="janino-*.jar"/>
| <include name="antlr-*.jar"/>
| <include name="commons-jci-*.jar"/>
| <include name="stringtemplate-*.jar"/>
| </fileset>
| <!-- Added for trinidad -->
| <fileset dir="${basedir}/resources/WEB-INF/lib">
| <include name="*.jar" />
| </fileset>
| </copy>
| <copy todir="${ear.dir}/META-INF">
| <fileset dir="${basedir}/resources/META-INF">
| <include name="application.xml" />
| <include name="jboss-app.xml" />
| </fileset>
| </copy>
| </target>
I have never used trinidad before so I am just trying to see if it is configured properly..
I add this xhtml page
| <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition xmlns="http://www.w3.org/1999/xhtml"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:ui="http://java.sun.com/jsf/facelets"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:tr="http://myfaces.apache.org/"
| template="layout/template.xhtml">
|
| <ui:define name="body">
|
| <tr:document title="NavigationModel Demo" maximized="true">
| <tr:form>
| <tr:panelPage>
| <f:facet name="branding">
| <tr:panelGroup layout="horizontal">
| <tr:objectIcon name="logo"/>
| <tr:outputText value="NavigationModel Demo"/>
| </tr:panelGroup>
| </f:facet>
| </tr:panelPage>
| </tr:form>
| </tr:document>
| </ui:define>
| </ui:composition>
|
which just renders the <tr:> elements directly into the html.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024748#4024748
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024748
17Â years, 10Â months