Bugs item #887832, was opened at 2004-01-30 21:56
Message generated for change (Comment added) made by lafr
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=887832&group_id=22866

Category: JBossCMP
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Frank Langelage (lafr)
Assigned to: Alexey Loubyansky (loubyansky)
Summary: finder does not find existing data

Initial Comment:
Bean MbiMenue with this finder-declaration processed by
XDoclet:
 * @ejb.finder signature="java.util.Collection
findByUsernameSprachKbez (java.lang.String username,
java.lang.String sprach_kbez)"
 *   view-type="local"
 *   query="SELECT OBJECT(o) FROM MbiMenue AS o WHERE
o.username = ?1 AND o.sprachKbez = ?2"
 *   result-type-mapping="Local"

This finder does not find data.
If I replace the variables ?1 and ?2 by constant values
the data is found.
I swichted on log level trace an saw, that the
variables are filled correctly, but they are filled as
jdbc-type VARCHAR.

But field username is defined
         *      column-name="username"
         *      sql-type="CHAR(8)"
         *      jdbc-type="CHAR"
and field sprach_kbez
         *      column-name="sprach_kbez"
         *      sql-type="CHAR(2)"
         *      jdbc-type="CHAR"

The table is created by jboss and the columns are of
the expected type.
If I switch the Oracle9i mapping for String from
VARCHAR to CHAR  the jdbc-type of the variables changes
from VARCHAR to CHAR but finder does not find anything.

System:
- current JBoss-3.2 branch
- JDK 1.4.2_03
- Solaris 9 on Sparc
- XDoclet 1.2
- Oracle 9i 9.2.0.4




----------------------------------------------------------------------

>Comment By: Frank Langelage (lafr)
Date: 2004-02-03 23:34

Message:
Logged In: YES 
user_id=300021

I created a this method on a stateless session bean named Mask:
    /**
     * @ejb.interface-method
     */
    public void testFinder() {
        try {
            javax.naming.Context ctx = new
javax.naming.InitialContext();
            javax.sql.DataSource ds =
(javax.sql.DataSource)ctx.lookup("java:/OracleDS");
            java.sql.Connection con = ds.getConnection();
            
            // first try with PreparedStatement
            String sqlQuery = "select * from mbi_menue where
username = ? and sprach_kbez = ?";
            logger.info( "executing '" + sqlQuery + "'" );
            java.sql.PreparedStatement ps =
con.prepareStatement(sqlQuery);
            ps.setString( 1, "mbi" );
            ps.setString( 2, "de" );
            java.sql.ResultSet rs = ps.executeQuery();
            int i = 0;
            while ( rs.next() ) {
                i++;
                logger.info("Zeile: " + i);
            }
            rs.close();
            ps.close();
            
            // second try with normal Statement
            sqlQuery = "select * from mbi_menue where
username = 'mbi' and sprach_kbez = 'de'";
            logger.info( "executing '" + sqlQuery + "'" );
            java.sql.Statement s = con.createStatement();
            rs = s.executeQuery( sqlQuery );
            i = 0;
            while ( rs.next() ) {
                i++;
                logger.info("Zeile: " + i);
            }
            rs.close();
            s.close();
            
            con.close();
        }
        catch( java.sql.SQLException sqle ) {
            logger.error( sqle.toString() );
        }
        catch( javax.naming.NamingException ne ) {
            logger.error( ne.toString() );
        }
    }

and got this result:
23:30:25,821 INFO  [Mask.testFinder] executing 'select *
from mbi_menue where username = ? and sprach_kbez = ?'
23:30:25,966 INFO  [Mask.testFinder] executing 'select *
from mbi_menue where username = 'mbi' and sprach_kbez = 'de''
23:30:26,001 INFO  [Mask.testFinder] Zeile: 1
23:30:26,004 INFO  [Mask.testFinder] Zeile: 2
23:30:26,006 INFO  [Mask.testFinder] Zeile: 3
23:30:26,008 INFO  [Mask.testFinder] Zeile: 4
23:30:26,035 INFO  [Mask.testFinder] Zeile: 5
23:30:26,037 INFO  [Mask.testFinder] Zeile: 6
23:30:26,040 INFO  [Mask.testFinder] Zeile: 7
23:30:26,042 INFO  [Mask.testFinder] Zeile: 8
23:30:26,044 INFO  [Mask.testFinder] Zeile: 9
23:30:26,046 INFO  [Mask.testFinder] Zeile: 10
.....


----------------------------------------------------------------------

Comment By: Alexey Loubyansky (loubyansky)
Date: 2004-02-03 13:59

Message:
Logged In: YES 
user_id=543482

Assume the datasource used for entity beans is java:/DefaultDS:

Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:/DefaultDS");

Connection con = ds.getConnection();
PreparedStatement ps = con.prepareStatement(sqlQuery);
ResultSet rs = ps.executeQuery();
...

----------------------------------------------------------------------

Comment By: Frank Langelage (lafr)
Date: 2004-02-03 08:11

Message:
Logged In: YES 
user_id=300021

Do you have an example for this ?
Perhaps a testcase somewhere in the testsuite ?


----------------------------------------------------------------------

Comment By: Alexey Loubyansky (loubyansky)
Date: 2004-02-03 02:00

Message:
Logged In: YES 
user_id=543482

If you try the same SQL with direct JDBC from JBoss will it
return the data?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=887832&group_id=22866


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to