Hi all.
I feel quite comfortable, reading your opinions.
As a matter of fact I went farther than I thought with this
approach.....instead of writing 100 JTables and 100 input forms
which substantially differ only for the query to put in the JComponents
I wrote 1 single JTable and 1 single input form.

The number of components / rendering / query is all inside the XML file

    <field>
        <name>Descrizione</name>
        <index>1</index>
        <rendering>JTextField</rendering>
        <sql>None</sql>
    </field>
    <field>
        <name>Reg.Iva</name>
        <index>2</index>
        <rendering>JComboBox</rendering>
        <sqlTable>SELECT description FROM lmt_vat_registry WHERE vat_code =
?</sqlTable>

..........
then I cached all the XML files in an Hashtable and I have ready for use
100 different Forms and JTables!

Happy if this little contribute will be of help to somebody.
ps. for Rickard: I pestered also RMI mailing list with questions today- hope
I won't annoy too much today :) !
Bye
Francesco

----- Original Message -----
From: Rickard �berg <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, November 29, 2000 10:48 AM
Subject: Re: 2 Basic questions about EJB


> On Wed, 29 Nov 2000 09:47:28 +0100, Francesco Marchioni
> <[EMAIL PROTECTED]> wrote:
> >1) Is it a bad idea to put plain SQL queries in Session Beans ?
> >
> >I need somewhere in my code to make generic Sql queries to fill up
> >some combos with values- since every combo has its own query
> >I provided a config file in XML with the single query for every combo.
> >
> >Then I just wrote a method in my Session bean a method like this:
> >
> >Collection readSQL (String sql, params) {
> >
> >... execute query with params
> >
> >....fill up Collection with Resultset
> >
> >...return Collection
> >}
> >
> >is it a clean solution- technically speaking? or do I need to
> >contact Entity Beans and use their find methods ?
>
> Seems like a good idea to me.
>
> One additional thing you may want to do is if the data is fairly static
> then cache the results in the session bean. I.e. keep a hashtable with
> sql as key and result collection as value. If the sql string is in the
> hashtable, then return the collection. If not then query the db and put
> the result in the hashtable. If the data is semi-static you could also
> use a timeout to refresh from the db. This will make your system much
> speedier and you will put less strain on the db. If you use a static
> hashtable make sure you use synchronized properly when updating the
> hashtable.
>
> /Rickard
>
> --
> Rickard �berg
>
> Email: [EMAIL PROTECTED]
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to