-->
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.  [ 1 post ] 
Author Message
 Post subject: Nothing generated for Hbm2ddl with annotations
PostPosted: Fri Feb 23, 2007 8:57 am 
Beginner
Beginner

Joined: Wed Jul 14, 2004 11:51 am
Posts: 43
Hi,

I'm having problems generating my database with hbm2ddl. I tried a simple mapping but it doesn't seem to work and I don't get any error messages (I use hibernate 3.2.0ga, hibernate-annotation 3.2.1.ga and hibernate-tools 3.2.0 beta )

Here is my cfg file:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory>

        <!-- Mapping for localization context -->
        <mapping class="org.dataisland.primitives.bean.LocalizationContext"/>

    </session-factory>
</hibernate-configuration>




Here is (part of) my class containing the annotations:

Code:
package org.dataisland.primitives.bean;

...

/**
* Localization context
*/
@org.hibernate.annotations.Entity(dynamicUpdate=true)
@javax.persistence.Table(name="LOCALIZATION_CONTEXT")
public class LocalizationContext implements Serializable {
...
    private String id;
    private boolean system;
    String humanReadableKey;
    List locales = new ArrayList();


    @javax.persistence.Id
    @javax.persistence.GeneratedValue(generator="uuid")
    @org.hibernate.annotations.GenericGenerator(name="uuid", strategy = "uuid.hex")
    @javax.persistence.Column(name="ID", length=32)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @org.hibernate.annotations.Type(type="boolean")
    @javax.persistence.Column(name="SYSTEM")
    public boolean isSystem() {
        return system;
    }

    public void setSystem(boolean system) {
        this.system = system;
    }

    @org.hibernate.annotations.Type(type="string")
    @javax.persistence.Column(name="HUMAN_READABLE_KEY")
    public String getHumanReadableKey() {
        return humanReadableKey;
    }

    public void setHumanReadableKey(String humanReadableKey) {
        this.humanReadableKey = humanReadableKey;
    }


    @org.hibernate.annotations.CollectionOfElements(fetch=javax.persistence.FetchType.EAGER )
    @javax.persistence.JoinTable(name="LOCALIZATION_CONTEXT2LOCALE",
                                 joinColumns = @javax.persistence.JoinColumn(referencedColumnName="LOCALIZATION_CONTEXT_FK"),
                                 inverseJoinColumns = @javax.persistence.JoinColumn(referencedColumnName="LOCALE"))
    @org.hibernate.annotations.IndexColumn(name="WEIGHT")
    public List<Locale> getLocales() {
        return locales;
    }

    public void setLocales(List<Locale> locales) {
        this.locales = locales;
    }

...
}



And finally here is my ant task:
Code:
    <target name="create.tables">
        <mkdir dir="${sql.output.dir}"/>
        <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
            <classpath refid="hibernate.classpath"/>
        </taskdef>

        <hibernatetool destdir="${sql.output.dir}" >
            <classpath>
               <pathelement location="${lib.dir}/dataisland-primitives.jar"/>
                <pathelement location="${classes.dir}"/>
            </classpath>
       
           <annotationconfiguration configurationfile="${cumul.conf.test.dir}/hibernate.cfg.xml"
                                    propertyfile="${cumul.conf.test.dir}/hibernate.properties"/>

           <hbm2ddl outputfilename="create-tables.sql" drop="true"/>
        </hibernatetool>
    </target>


Which gives this output:

Code:
Buildfile: build.xml

create.tables:
[hibernatetool] Executing Hibernate Tool with a Hibernate Annotation/EJB3 Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
[hibernatetool] 2007-02-23 07:54:42 org.hibernate.cfg.annotations.Version <clinit>
[hibernatetool] INFO: Hibernate Annotations 3.2.1.GA
[hibernatetool] 2007-02-23 07:54:42 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2.0
[hibernatetool] 2007-02-23 07:54:42 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 2007-02-23 07:54:42 org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] 2007-02-23 07:54:42 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate.cfg.xml
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: null
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.dialect.Dialect <init>
[hibernatetool] INFO: Using dialect: org.dataisland.primitives.hibernate.dialect.DataIslandHibernateMySQLDialect
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: Running hbm2ddl schema export
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: writing generated schema to file: D:\dev\projects\v2--mdarad-genapp\samples\totaltest\output\sql\c
reate-tables.sql
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: exporting generated schema to database
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: Using Hibernate built-in connection pool (not for production use!)
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: Hibernate connection pool size: 20
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: autocommit mode: false
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/totaltest
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.connection.DriverManagerConnectionProvider configure
[hibernatetool] INFO: connection properties: {user=totaltest, password=****}
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.tool.hbm2ddl.SchemaExport execute
[hibernatetool] INFO: schema export complete
[hibernatetool] 2007-02-23 07:54:43 org.hibernate.connection.DriverManagerConnectionProvider close
[hibernatetool] INFO: cleaning up connection pool: jdbc:mysql://localhost:3306/totaltest

BUILD SUCCESSFUL


As you can see, no classes seem to be mapped, nothing was created in the database and I have no error messages.

Any clue what my problem is?

Thanks

François[/code]


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

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.