probleme de generation d'une DDL
Bonjour à tous
je suis débutant en Java, je suis entrain de suivre le tuto de Serge Tahé sur la persistance via JPA sous eclipse que je trouve tres bon, je trouve également cette communauté tres bonne et réactif:ccool:.
j'utilise eclipse-jee-ganimede-SR2 sous Windows xp
Mon problème est le suivant: lors de la génération d'une base de donnée via le script ant suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <project name="jpa-hibernate" default="compile" basedir=".">
<!-- nom du projet et version -->
<property name="proj.name" value="jpa-hibernate" />
<property name="proj.shortname" value="jpa-hibernate" />
<property name="version" value="1.0" />
<!-- Propriété globales -->
<property name="src.java.dir" value="src" />
<property name="lib.dir" value="../../../lib" />
<property name="build.dir" value="bin" />
<!-- le Classpath du projet -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- les fichiers de configuration qui doivent être dans le classpath-->
<patternset id="conf">
<include name="**/*.xml" />
<include name="**/*.properties" />
</patternset>
<!-- Nettoyage projet -->
<target name="clean" description="Nettoyer le projet">
<delete dir="${build.dir}" />
<mkdir dir="${build.dir}" />
</target>
<!-- Compilation projet -->
<target name="compile" depends="clean">
<javac srcdir="${src.java.dir}" destdir="${build.dir}" classpathref="project.classpath" />
</target>
<!-- Copier les fichiers de configuration dans le classpath -->
<target name="copyconf">
<copy todir="${build.dir}">
<fileset dir="${src.java.dir}">
<patternset refid="conf" />
</fileset>
</copy>
</target>
<!-- Hibernate Tools -->
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.classpath" />
<!-- Générer le schéma de la base -->
<target name="DDL" depends="compile, copyconf" description="Génération DDL base">
<hibernatetool destdir="${basedir}">
<classpath path="${build.dir}" />
<!-- Utiliser META-INF/persistence.xml -->
<jpaconfiguration />
<!-- export -->
<hbm2ddl drop="true" create="true" export="false" outputfilename="ddl/schema.sql" delimiter=";" format="true" />
</hibernatetool>
</target>
<!-- Générer la base -->
<target name="BD" depends="compile, copyconf" description="Génération BD">
<hibernatetool destdir="${basedir}">
<classpath path="${build.dir}" />
<!-- Utiliser META-INF/persistence.xml -->
<jpaconfiguration />
<!-- export -->
<hbm2ddl drop="true" create="true" export="true" outputfilename="ddl/schema.sql" delimiter=";" format="true" />
</hibernatetool>
</target>
</project> |
he bien pour une raison que j'ignore le fichier sql "schema.sql" est crée mais ne contient rien vide apres consultation de ma console qui affiche ceci:
Buildfile: C:\Documents and Settings\Administrateur\workspace\hibernate-personnes-entites\ant-hibernate.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12
| clean:
[delete] Deleting directory C:\Documents and Settings\Administrateur\workspace\hibernate-personnes-entites\bin
[mkdir] Created dir: C:\Documents and Settings\Administrateur\workspace\hibernate-personnes-entites\bin
compile:
[javac] Compiling 3 source files to C:\Documents and Settings\Administrateur\workspace\hibernate-personnes-entites\bin
copyconf:
[copy] Copying 2 files to C:\Documents and Settings\Administrateur\workspace\hibernate-personnes-entites\bin
BD:
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
[hibernatetool] 1. task: hbm2ddl (Generates database schema)
BUILD SUCCESSFUL
Total time: 8 seconds |
tandis que d'apres le cours je dois voir normalement ceci :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| 1. Buildfile: C:\data\2006-2007\eclipse\dvp-jpa\hibernate\direct\personnes-entites\ant-hibernate.xml
2. c lean:
3. [delete] Deleting directory C:\data\2006-2007\eclipse\dvp-jpa\hibernate\direct\personnesentites\
bin
4. [mkdir] Created dir: C:\data\2006-2007\eclipse\dvp-jpa\hibernate\direct\personnes-entites\bin
5. c ompile:
6. [javac] Compiling 3 source files to C:\data\2006-2007\eclipse\dvpjpa\
hibernate\direct\personnes-entites\bin
7. c opyconf:
8. [copy] Copying 2 files to C:\data\2006-2007\eclipse\dvp-jpa\hibernate\direct\personnesentites\
bin
9. DDL:
10. [hibernatetool] Executing Hibernate Tool with a JPA Configuration
11. [hibernatetool] 1. task: hbm2ddl (Generates database schema)
12. [hibernatetool] drop table if exists jpa01_personne;
13. [hibernatetool] create table jpa01_personne (
14. [hibernatetool] ID integer not null auto_increment,
15. [hibernatetool] VERSION integer not null,
16. [hibernatetool] NOM varchar(30) not null unique,
17. [hibernatetool] PRENOM varchar(30) not null,
18. [hibernatetool] DATENAISSANCE date not null,
19. [hibernatetool] MARIE bit not null,
20. [hibernatetool] NBENFANTS integer not null,
21. [hibernatetool] primary key (ID)
22. [hibernatetool] ) ENGINE=InnoDB;
23. BUILD SUCCESSFUL
24. Total time: 5 seconds |
aussi j'ai l'impression que dans mon code la ligne 48:
Code:
48 : <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.classpath" />
n'est pas executer correctement et je ne sais pourquoi aider moi svp.
merci d'avance
ps:
la base de donnée de donnée est MySQL 5.5 et voici le fichier de configuration persistance.xml:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="jpa" transaction-type="RESOURCE_LOCAL">
<!-- provider -->
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<!-- Classes persistantes -->
<property name="hibernate.archive.autodetection" value="class, hbm" />
<!-- logs SQL
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="use_sql_comments" value="true"/>
-->
<!-- connexion JDBC -->
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jpa" />
<property name="hibernate.connection.username" value="jpa" />
<property name="hibernate.connection.password" value="jpa" />
<!-- création automatique du schéma -->
<property name="hibernate.hbm2ddl.auto" value="create" />
<!-- Dialecte -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<!-- propriétés DataSource c3p0 -->
<property name="hibernate.c3p0.min_size" value="5" />
<property name="hibernate.c3p0.max_size" value="20" />
<property name="hibernate.c3p0.timeout" value="300" />
<property name="hibernate.c3p0.max_statements" value="50" />
<property name="hibernate.c3p0.idle_test_period" value="3000" />
</properties>
</persistence-unit>
</persistence> |