Announcement Announcement Module
Collapse
No announcement yet.
How a hypersonic db is created in Spring Life tutorial? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How a hypersonic db is created in Spring Life tutorial?

    Hi,

    I have download "Spring Live" sample example in order to learn Spring framework.
    I did not understand and "ant deploy", how a hypersonic data base could be created. But it is the case.

    I checked target "deploy" and "compile", nowhere could I see the creation of database.

    Any explaination?

    Thanks!

    PY


    <target name="deploy" depends="compile" description="Deploy application">
    <copy todir="${tomcat.home}/webapps/${webapp.name}" preservelastmodified="true">
    <fileset dir="${web.dir}">
    <include name="**/*.*" />
    <exclude name="**/junit.jar" />
    <exclude name="**/*mock.jar" />
    <exclude name="**/strutstestcase*.jar" />
    </fileset>
    </copy>
    <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF/classes" preservelastmodified="true">
    <fileset dir="${build.dir}/classes" />
    </copy>
    </target>


    <target name="compile" description="Compile main source tree java files">
    <mkdir dir="${build.dir}/classes" />
    <javac destdir="${build.dir}/classes" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
    <src path="${src.dir}" />
    <classpath refid="classpath" />
    </javac>

    <mkdir dir="${test.dir}/classes" />
    <javac destdir="${test.dir}/classes" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
    <src path="${test.src}" />
    <classpath>
    <path refid="classpath" />
    <path location="${build.dir}/classes" />
    </classpath>
    </javac>

    <copy todir="${build.dir}/classes">
    <fileset dir="${src.dir}" includes="**/*.hbm.xml" />
    </copy>
    </target>

  • #2
    hsql can be configured to run as an inmemory database. Extremely useful for testing

    Comment


    • #3
      Originally posted by yatesco
      hsql can be configured to run as an inmemory database. Extremely useful for testing
      Indeed. But I could not find where it is configured.

      Comment


      • #4
        Checkout the hsqldb docs http://hsqldb.sourceforge.net/doc/gu...04.html#N108C6. It is configured in the jdbc url.

        The url would be specified where the datasource is configured, I presume in one of the spring context files.

        I have been known to be completely dense and miss the whole point of the question If I have done, please say, and re-iterate using really small words for me

        Comment


        • #5
          Originally posted by yatesco
          Checkout the hsqldb docs http://hsqldb.sourceforge.net/doc/gu...04.html#N108C6. It is configured in the jdbc url.

          The url would be specified where the datasource is configured, I presume in one of the spring context files.

          I have been known to be completely dense and miss the whole point of the question If I have done, please say, and re-iterate using really small words for me

          Comment


          • #6
            confs: can you repost please

            Comment


            • #7
              Re: How a hypersonic db is created in Spring Life tutorial?

              Originally posted by confs
              Hi,

              I have download "Spring Live" sample example in order to learn Spring framework.
              I did not understand and "ant deploy", how a hypersonic data base could be created. But it is the case.

              I checked target "deploy" and "compile", nowhere could I see the creation of database.

              Any explaination?

              Thanks!

              PY


              <target name="deploy" depends="compile" description="Deploy application">
              <copy todir="${tomcat.home}/webapps/${webapp.name}" preservelastmodified="true">
              <fileset dir="${web.dir}">
              <include name="**/*.*" />
              <exclude name="**/junit.jar" />
              <exclude name="**/*mock.jar" />
              <exclude name="**/strutstestcase*.jar" />
              </fileset>
              </copy>
              <copy todir="${tomcat.home}/webapps/${webapp.name}/WEB-INF/classes" preservelastmodified="true">
              <fileset dir="${build.dir}/classes" />
              </copy>
              </target>


              <target name="compile" description="Compile main source tree java files">
              <mkdir dir="${build.dir}/classes" />
              <javac destdir="${build.dir}/classes" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
              <src path="${src.dir}" />
              <classpath refid="classpath" />
              </javac>

              <mkdir dir="${test.dir}/classes" />
              <javac destdir="${test.dir}/classes" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
              <src path="${test.src}" />
              <classpath>
              <path refid="classpath" />
              <path location="${build.dir}/classes" />
              </classpath>
              </javac>

              <copy todir="${build.dir}/classes">
              <fileset dir="${src.dir}" includes="**/*.hbm.xml" />
              </copy>
              </target>

              Let me described my "problem" again(it is not really a problem but a miracle that I could not understand").

              I deleted the hypersonic database files in "my tomcat home folder"/bin/db. Then I run again "ant deploy", it appeared again.

              But no where in build.xml traget "deploy" I could see the database definition scripts. How could it be created?

              Thanks again for any new explaination.

              Confs

              Comment


              • #8
                OK, without actually looking I am flying by the seat of my pants

                I expect somewhere in the spring configuration there will be a persistence.xml. In here there will be a datasource configured which will contain a "url" setting. This url setting will probably be something like "jdbc:hsql:." (cannot remember exactly what) which basically tells hypersoniq to create a *new* database everytime an instance of the datasource is created. (Actually, if there are files, the url is most like "jdbc:hsq:mydb.file").

                Hibernate can be configured to create the database during loading (hbm.export or something?), or the unit tests might be writing tear up/down methods which create the database.

                Do a search for "jdbc" in the xml files and read the unit test sources and I am sure that will shine a light

                Comment


                • #9
                  BTW; If I am right it will only create the database during unit testing, so deploy probably depends on a unit test ant target.

                  Alternatively I might be barking *completely* up the wrong tree and the same actually uses a template database which it simply copies

                  Comment

                  Working...
                  X