The following method solves the problem of dynamic matching of Like under JBoss:
For example: Select Object (p) from TBA P where p.Name Like? 1 ----> This method is in the jboss.
-------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------
Disclaimer: This NB method is not the younger brother, but ACCP (QQ: unfold green) original, the younger brother is taught by him. I don't dare to enjoy alone. What is the high meeting, please consultant. Welcome to post. Encourage sharing. !
1. Create a Finder method first, FindBylike (String ABC, Object [] AGRS)
The parameter name can be casually, but the type must be above, this is the specified
2. The QL statement inside is maintained,
3. Also write a method, such as getidByValue (Value);
Public Collection GetidByvalue (String Value) THROWS FINDEREXCEPTION {
StringBuffer jbossql = new stringbuffer ();
JBossql.Append ("Select O.id from Teacher O Where");
JBossql.Append ("oNAME LIKE? 1");
Object [] args = new object [1];
Args [0] = "%" Value "%";
Return FindbyLike (jbossql.tostring (), args);
}
Where FindbyLike (JBossql.toTString (), ARGS is the empty method created by the first step.
What you want to call is this method, and the QL statement inside can be used to change itself.
In ejb-jar.xml, you can find XML descriptions of the empty Finder method you just created.
Method-Params>
query-method>
query>
Put these content to jbosscmp-jdbc.xml (the corresponding entity bean
Change the
To this compilation, deployment, big success