4 Replies Latest reply on Oct 7, 2008 11:40 AM by peterj

    How to Clear(Reset) database with Jboss?

    pioner01

      Can somebody help me with this little issue.
      I have enterprise application as ear file with several different entity beans inside that are mapped to postgreSQL database.
      What is the easiest way to perform something like "Drop all table`s from database " or "Delete * from all table`s"?
      And if it`s such complicated is there any way to get all beans(names->tables) deployed from some contexts within jboss?
      Thank you for your help.

        • 1. Re: How to Clear(Reset) database with Jboss?
          peterj

          Are you using Hibernate or EJB3? If so, you could set hibernate.hbm2ddl.auto to "create" or "create-drop".

          If you are using JDBC directly, or EJB2.x, you will probably have to use database tools to drop the tables or the table contents. Or you could have a servlets init method fire off the JDBC request.

          • 2. Re: How to Clear(Reset) database with Jboss?
            pioner01

            It`s EJB3.0 project.

            If so, you could set hibernate.hbm2ddl.auto to "create" or "create-drop".

            For me it seems like a property to allow appserver to drop table`s but there is nothing how to force such procedure.

            • 3. Re: How to Clear(Reset) database with Jboss?
              pioner01

              I`ve found a vendor specific solution for Postges but for sure that`s not what i want because the only place in project where i refer to postgres is in projectname-ds file in deploy directory and of course it may be changed to oracle ...etc.So such a utility to reset database shouldn`t depend on database vendor.

              • 4. Re: How to Clear(Reset) database with Jboss?
                peterj

                Use "create-drop". The tables will be created at strup and dropped at shutdown (or perhaps simply replaced on next startup, I haven't watched the behavior that closely).