-
1. Re: how does the @jboss:finder-query tag work?
vashistvishal Jul 5, 2003 6:52 AM (in response to toddlisonbee)ejb-jar.xml is where deployment descriptors are written for EJB.
web.xml has deployment descriptor for web components, ex servlet name, url-pptern etc.
jaws.xml is used by JAWS, which is the O/R mapper, used by JBoss to manage CMP entity beans.
What you can do with standardjaws.xml / jaws.xml:
Specify a datasource and the type-mappings to use with it
Set a bunch of options concerning jaws behavior
Specify how JAWS should build/use your tables
Define finders to access you entity beans
For your question on EJB QL type, why dont you look into EJP specs.
I hope this helps... -
2. Re: how does the @jboss:finder-query tag work?
edross Jul 8, 2003 7:05 AM (in response to toddlisonbee)This may be a bit late for you, but I was having the same problem. I was under the impression the @jboss.finder-query should have put an entry into the jbosscmp-jdbc.xml file for the finder. If it does, I could find the magic to make it happen.
Here's what I did, Defined a normal finder (but left the query blank in the xdoc tag) then I defined a @jboss.query (NOTE NOT FINDER-QUERY). This puts an entry in the ejb-jar.xml for the finder and an entry in the jbosscmp-jdbc.xml for the query. Seems to work great. -
3. Re: how does the @jboss:finder-query tag work?
vashistvishal Jul 8, 2003 10:32 PM (in response to toddlisonbee)@ejb:finder signature="test.interfaces.Manager findByName( java.lang.String pSurname, java.lang.String pLastName )"
@jboss:finder-query name="findByName" query="First_Name = {0} AND Last_Name = {1}"
After this message posted by edross, I had a look at Jboss Quick start guide to see, if there is something like this you can do.
And this is what is give on pg-31.
It seems to me you can override yr query in jboss tags after leaving the query in ejb tags.
Hopefully this works for you.
Cheers... -
4. Re: how does the @jboss:finder-query tag work?
toddlisonbee Jul 24, 2003 4:05 PM (in response to toddlisonbee)
Thanks for the replies,
they helped in understanding some things,
i eventually solved my problem...
here is my solution:
my main problem was wanting to do something like this
* @ejb:finder signature="java.util.Collection findByFoo( java.lang.String pFoo )"
* query ="SELECT OBJECT(o) FROM Customer o WHERE o.foo LIKE '%?1%'"
I never figured out a way to use LIKE with the % symbols though.
EntityBeans seem faily limited in what you can do with queries and inserts, updates are nice though. (I'm not sure how other app servers compare on these points).
What I ended up doing was breaking away from the J2EE model, by-passing the entity beans and just getting a JDBC connection and executing a query.
There is probably some better/more official JBoss way to do this (I still have no idea what that might be) but this worked great as a Quick and Easy get the job done approach.
I ended up using this approach to solve a number of problems in my application.
Here it is:
import javax.sql.DataSource;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.Context;
import java.sql.PreparedStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.util.Vector;
//do all of the following in some method() in a stateless session bean
DataSource dataSource = null;
Connection conn = null;
Vector returnVector = new Vector();
//get the database connection
try
{
Context ctx = new InitialContext ();
dataSource = (DataSource) ctx.lookup ("java:/PostgresDS");
conn = dataSource.getConnection ();
}
catch (SQLException e) { System.out.println(e); }
catch (NamingException e) { System.out.println("Naming Exception => " + e); }
try
{
String queryString = "Select customer_id, f_name, l_name, address, city, state, zip, phone" +
" from customer " +
" where l_name Like ? ";
pstmt.setString(1, "%" + lastName + "%" );
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
CustomerData record_data = new CustomerData();
record_data.setCustomerId( rs.getInt("customer_id") );
record_data.setCardFirstName(rs.getString("f_name") );
record_data.setCardLastName(rs.getString("l_name") );
record_data.setAddress(rs.getString("address") );
record_data.setCity(rs.getString("city") );
record_data.setState(rs.getString("state") );
record_data.setZip(rs.getString("zip") );
record_data.setPhone(rs.getString("phone") );
returnVector.add( record_data );
}
pstmt.close();
conn.close();
}
catch (SQLException e)
{
System.out.println("SqlException => " + e);
}
return returnVector;
-----------------------------------------------------------
I hope this helps someone else with a similar problem.
Todd Lisonbee