7 Replies Latest reply on Apr 26, 2009 8:03 PM by gdfgd eqwe

    import.sql

    marx3 Apprentice

      There is possibility to execute import.sql script, but only on startup and only if create is set in persistance.xml
      I would like to manually execute other script from my application.
      How can I do that?

        • 1. Re: import.sql
          Nicklas Karlsson Master

          Marek Nazarko wrote on Mar 03, 2008 09:54 AM:


          There is possibility to execute import.sql script, but only on startup and only if create is set in persistance.xml
          I would like to manually execute other script from my application.
          How can I do that?


          Not tried but:


          You should be able to dig out a JDBC connection from the entityManger delegate (or lookup it in JNDI), parse the script and run the statements yourself.

          • 2. Re: import.sql
            marx3 Apprentice

            It's hard way, and I did it, but I'm looking for an easy way. I'm sure it's possible, but I need an example.

            • 3. Re: import.sql
              Nicklas Karlsson Master

              My final offer: aquire resource, put it through BufferedReader.readLine() and pass it along to the entityManager.createNativeQuery() ;-)


              I would be surprised if there was an API for running a native script but feel free to surprise me...

              • 4. Re: import.sql
                marx3 Apprentice

                Seam has something.
                Import.sql file is used in Seam only, and Seam executes it after schema is generated. I suspect it uses some sort of Observer to execute it just then.
                I want to do something similair (for example, I want to execute script even if update is set in persistence.xml)

                • 5. Re: import.sql
                  Nicklas Karlsson Master

                  Marek Nazarko wrote on Mar 03, 2008 11:52 AM:


                  Seam has something.
                  Import.sql file is used in Seam only, and Seam executes it after schema is generated. I suspect it uses some sort of Observer to execute it just then.


                  I think import.sql is more a hibernate-thing than a seam-thing. looking through the source code would probably reveal how the import is done (and can you access the API)

                  • 6. Re: import.sql
                    marx3 Apprentice

                    I've gave up. Now I simply want to use import.sql as intended. I simply put there


                    execute my_procedure



                    and I get java.sql.SQLSyntaxErrorException: ORA-00900:

                    • 7. Re: import.sql
                      gdfgd eqwe Novice

                      Hi!


                      The problem was solved?


                      thx