Dynamic query and read-ahead - Help needed!
vbatista Nov 21, 2002 8:53 PMHello!
I am using JBoss 3.0.2 with bundled Tomcat 4.0.4.
I am having problems using "read-ahead" with Dynamic queries. I configure my dynamic finder with the read-ahead feature, but it simply ignores them and behaves always the same. With no Dynamic queries, it works great.
I configured my finder using Xdoclet. The Xdcolet configuration, the ejb-jar.xml extract and the jbosscmp-jbcd.xml extract are appended below.
I need the dynamic feature because I need to execute a "SELECT...WHERE xpto IN (..,..)".
Below are two log messages extracted from the JBoss log when my dynamic query was a simple "Select".
When I execute the finder (1), the query returns all columns (no matter if my strategy is "on-load" or "on-find"). After this, if I execute one method which returns one Value Object with all the columns, another select is automatically executed by the
container (2). This select shouldn't be necessary once I am still in the same transaction, so the previous data is still valid.
If I only access columns from the Primary Key (instead of getting the VO with all columns), the select (2) isn't executed.
I have concluded that I can't configure ?read-ahead? on Dynamic queries. Is this the expected behavior? Is it related with the JBoss version I am using? Am I doing any thing wrong? I don't want to execute two consecutive selects which return the same data.......
Any help would be really appreciated!!
Thanks in advance,
Victor Batista
(1)
2002-11-22 00:17:11,109 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCDynamicQLQuery.User.findAllIn] Executing SQL: SELECT t0_u.username, t0_u.name, t0_u.surname, t0_u.passwd, t0_u.int_num, t0_u.description, t0_u.creation_date FROM DC_USERS t0_u WHERE t0_u.username = 'vbatista'
(2)
2002-11-22 00:17:11,129 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.User] Executing SQL: SELECT name, surname, passwd, int_num, description, creation_date FROM DC_USERS WHERE (username=?) FOR UPDATE
################ XDOCLET CONFIGURATION
* @ejb:finder signature="java.util.Collection findGeneric(java.lang.String query, java.lang.Object[] args)"
* query=""
*
* @jboss:query signature="java.util.Collection findGeneric(java.lang.String query, java.lang.Object[] args)"
* dynamic = "true"
* strategy="on-load"
################ EJB-JAR
<query>
<query-method>
<method-name>findGeneric</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.Object[]</method-param>
</method-params>
</query-method>
<ejb-ql><![CDATA[]]></ejb-ql>
</query>
################ JBOSSCMP-JDBC
<query>
<query-method>
<method-name>findGeneric</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.Object[]</method-param>
</method-params>
</query-method>
<dynamic-ql/>
<read-ahead>
<strategy>on-find</strategy>
</read-ahead>
</query>