10 Replies Latest reply on Oct 27, 2003 11:41 AM by mkotsbak

    Can't get "no-select-before-insert" to work

    nbirch

      Hi,

      I'm trying to eliminate the "SELECT COUNT(*) FROM XX WHERE PrimaryKey=YY" that JBoss uses to test for an already existing bean in the table. So I'm enabling the "no-select-before-insert" command in standardjbosscmp-jdbc.xml in the defaults section at the top of the file, as follows:

      <entity-command name="no-select-before-insert"/>


      My deploy/sqlexception-service.xml file contains the default content:

      <?xml version="1.0" encoding="UTF-8"?>






      When I run jboss the server.log shows the following:

      16:46:07,291 INFO [MainDeployer] Starting deployment of package: file:/opt/fpdirector-3.2.1/jboss/server/fpdirector/deploy/sqlexception-service.xml
      16:46:07,326 INFO [MainDeployer] Deployed package: file:/opt/fpdirector-3.2.1/jboss/server/fpdirector/deploy/sqlexception-service.xml

      It doesn't say "Creating or Starting" so did it really start the SQLExceptionProcessor MBean??

      Has anyone managed to get no-select-before-insert to work??

      Thanks
      NBirch






        • 1. Re: Can't get "no-select-before-insert" to work
          lafr

          "no-select-before-insert" works for me and improved the performance of my app.

          In server.log I also only see "Starting" and "Deployed".

          • 2. Re: Can't get "no-select-before-insert" to work
            samart

            at the top of my jbosscmp-jdbc, i have a defaults section. try that.

            <jbosscmp-jdbc>


            java:/Mydb
            <datasource-mapping>Sybase</datasource-mapping>
            <entity-command name="no-select-before-insert"/>


            <enterprise-beans>...

            • 3. Re: Can't get "no-select-before-insert" to work
              nbirch

              I put the <entity-command name= "no-select-before-insert/> in the defaults section of the "standardjbosscmp-jdbc.xml" file.

              I don't have a jbosscmp-jdbc.xml file.
              Could this be the problem?

              Where should a jbosscmp-jdbc.xml be located, and what should its format be? IS it just overrides from the 'standard', like jboss.xml is to standardjboss.xml?

              Thanks,
              Nbirch

              • 4. Re: Can't get "no-select-before-insert" to work
                samart

                i dont know if not having jbosscmp-jdbc.xml is the problem. i woudl assume that if you edited standardjbosscmp-jdbc.xml, it shoudl work.

                if you dont have a jbosscmp-jdbc.xml (for each ejb.jar), then jboss uses all the defaults. in this file, you specify the field column mappings (so you have control), tabel creation, table names, relationship mappings, as well as override standardjbosscmp-jdbc.xml settings, etc.

                this might sound stupid, but are you sure you are editing the right standardjbosscmp-jdbc.xml (in the active instance directory?) e.g...the file for 'defaults', and not the one for 'all'?

                • 5. Re: Can't get "no-select-before-insert" to work
                  samart

                  the dtd for jbosscmp-jdbc.xml is in the docs/dtd dir. also, dishing out $10 for the docs, may be useful. i dont see how i coudl use cmp pain free without the docs.

                  • 6. Re: Can't get "no-select-before-insert" to work
                    nbirch

                    I'm definately using the right standardjbosscmp-jdbc.xml file. So maybe its not a config problem?

                    Could it be somthing about the INSERT or the Table I'm inserting into? Does the primary key field value need to be first in the INSERT statement arg list?

                    Thanks
                    NBirch

                    • 7. Re: Can't get "no-select-before-insert" to work
                      samart

                      No, the parameter order doesnt matter. typically, the container will create the row (insert) with the pk, then do an update (update) for all other bean values. (inefficient yes..but i dont know whats best, i've never tried to wire a cmp engine)

                      try making a minimal jbosscmp-jdbc.xml file like below. just place it next to your ejb-jar.xml in your jar/ear. if this doesnt work...sorry dude...i dunno. i just did this yesterday (disabled select before insert), and it worked for me. jb3.2.1. good luck..gotta get back to my behind schedule project! :)

                      <?xml version="1.0" encoding="UTF-8"?>
                      <jbosscmp-jdbc>


                      java:/PRSdb
                      <datasource-mapping>Sybase</datasource-mapping>
                      <entity-command name="no-select-before-insert"/>


                      </jbosscmp-jdbc>

                      • 8. Re: Can't get "no-select-before-insert" to work
                        nbirch


                        Thanks for the suggestion. I tried the minimal jbosscmp-jdbc.xml file idea, but it still gives me the SELECT before the INSERT. I'm wondering if this is a feature that only works for EJB2.0 beans? I'm still using EJB1.1.

                        Thanks again,
                        Nbirch

                        • 9. Re: Can't get "no-select-before-insert" to work
                          fbiaggi

                          You are correct, not handled in jaws.
                          See class org.jboss.ejb.plugins.jaws.jdbc.JDBCCreateEntityCommand
                          Ciao.

                          • 10. Re: Can't get "no-select-before-insert" to work
                            mkotsbak

                            This option seems to be added in jboss 3.2.x (as I can see in the DTD)