Is there a way to get the Hibernate hbm2ddl Ant task to exclude certain tables?

I use Hibernate to automatically create my database for testing, and I have some tables in my schema that contain static data that take a very long time to import. I used to use the following code in an assembly file to create a database (from map files):

<target name="schema-gen" depends="hibernate-gen">
    <taskdef name="schemaexport" classname="org.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="project.classpath" />

    <schemaexport properties="resources/hibernate.properties" text="false" quiet="false" delimiter=";" output="schema.sql">
        <fileset dir="${build.doclets}">
            <include name="**/*.hbm.xml" />
            <exclude name="**/inert/*.hbm.xml" />
        </fileset>
    </schemaexport>
</target>

.Hbm.xml files were generated using XDoclet. I move on to using Hibernate annotations for mapping, so I go on to hibernatetools to create a schema:

<target name="annotations-export" depends="hibernate-gen">
    <hibernatetool destdir="${basedir}">
        <annotationconfiguration configurationfile="${basedir}/resources/hibernate.cfg.xml" propertyfile="${basedir}/resources/hibernate.properties" />
        <classpath>
            <path refid="project.classpath" />
        </classpath>
        <hbm2ddl drop="true" create="true" export="true" outputfilename="schema.sql" delimiter=";" format="true" />
    </hibernatetool>
</target>

I would like to tell hbm2ddl to leave the classes in the "inert" package, as before, using schemaexport. Does anyone know if there is a way to do this?

+3
4

, , Hibernate , , Hibernate .

+1

:

<target name="annotations-export" depends="hibernate-gen">
    <hibernatetool destdir="${basedir}">
        <annotationconfiguration configurationfile="${basedir}/resources/hibernate.cfg.xml" propertyfile="${basedir}/resources/hibernate.properties">
            <fileset dir="${build.doclets}">
                <include name="**/*.class" />
                <exclude name="**/inert/*.class" />
            </fileset>
        </annotationconfiguration>
        <classpath>
            <path refid="project.classpath" />
        </classpath>
        <hbm2ddl drop="true" create="true" export="true" outputfilename="schema.sql" delimiter=";" format="true" />
    </hibernatetool>
</target>
+2

hbmddl?

<hbm2ddl update="true" ...

.

0

, , Hibernate , :

<class name="FooClass" table="FOO_TABLE"></class>

<class name="Foo" subselect="select * from FOO_TABLE">
  <synchronize table="FOO_TABLE">
</class>

, . , , .

subselect (): .

, Table.isPhysicalTable. AbstractUnionTables, .

.

, . , subselect .

, , , .

0

Source: https://habr.com/ru/post/1730072/


All Articles