Reverse-engineering : comment générer du code avec Eclipse ?
Bonjour,
Je débute en persistence Java. J'ai choisi Hibernate comme solution de reverse-engineering (création des entités Java à partir de mes tables SQL), avec le moins de fichiers de configuration possible (annotations JPA).
Dans un premier temps, j'essaie de générer le code Java grâce aux outils natifs JPA d'Eclipse. Alors que tout semble bien configuré, impossible d'accéder au schéma "public" de ma base :
http://www.monsterup.com/upload/1235462358.png
J'installe alors les JBoss Tools. Ca fonctionne mal, mais je trouve un bricolage pour arranger les choses. Tout est configuré, mais la génération de code ne donne rien, pas un message, pas un fichier !
Comme je suis dans une impasse, je vais tenter de détailler au mieux la configuration de mon projet Eclipse, afin d'arriver à faire fonctionner l'un ou l'autre de ces outils :
Build path
http://www.monsterup.com/upload/1235462711.png
Hibernate settings
http://www.monsterup.com/upload/1235463020.png
JPA settings
http://www.monsterup.com/upload/1235463138.png
hibernate.cfg.xml
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <?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>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">xxxxxx</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/jpa</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
</session-factory>
</hibernate-configuration> |
hibernate.properties
Code:
1 2 3 4 5
| hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql://localhost:5432/jpa
hibernate.connection.username=postgres
hibernate.connection.password=xxxxxx
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect |
hibernate.reveng.xml
Code:
1 2 3
| <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering /> |
Database explorer
http://www.monsterup.com/upload/1235463498.png
Hibernate configuration
http://www.monsterup.com/upload/1235463602.png
Hibernate code generator configuration
http://www.monsterup.com/upload/1235463758.png
http://www.monsterup.com/upload/1235463824.png
Merci de votre aide...