-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Is it possible to create databases with Hibernate?
PostPosted: Wed Nov 19, 2003 3:06 pm 
Beginner
Beginner

Joined: Sun Oct 05, 2003 9:07 am
Posts: 47
I currently use the following tasks to create my database and build it's schema:

Code:
    <target name="db-create" depends="define-tasks"
        description="create database for ${database.type}">
        <echo>Creating database with file: ${database.type}-create.sql</echo>
        <sql
            driver="${hibernate.connection.driver_class}"
            url="${database.name}"
            userid="${hibernate.connection.username}"
            password="${hibernate.connection.password}">
           
            <classpath refid="hibernate.classpath" />           
           
            <fileset dir="metadata/sql">               
                <include name="${database.type}-create.sql"/>
            </fileset>
        </sql>     
    </target>
   
    <!-- =================================================================== -->
    <!-- The "db-init" target generates the database schema and creates       -->
    <!-- tables based on the mapping files                                   -->
    <!-- =================================================================== -->
    <target name="db-init" depends="clean,package-ejb"
        description="creates database tables">
        <taskdef name="schemaexport"
            classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
            <classpath>
                <path refid="xdoclet.classpath" />
                <path refid="hibernate.classpath" />
            </classpath>
        </taskdef>
     
        <schemaexport quiet="no" text="no" drop="no"
           properties="database.properties">
           <fileset dir="${build.dir}/ejb/gen">
               <include name="**/*.hbm.xml"/>
           </fileset>
        </schemaexport>
    </target>


If ${database.type} is mysql, then it uses a mysql-create.sql file.

create database if not exists appfuse;
grant all privileges on appfuse.* to test@"%" identified by "test";
grant all privileges on appfuse.* to test@localhost identified by "test";

Rather than creating database scripts for all databases, it it possible for Hibernate to create the database (vs. maybe schemaexport task or SchemaExport class) for me?

Thanks,

Matt[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 7:44 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
no, SchemaExport doesn't do this


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.