IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

Hibernate + PostgerSQL


Sujet :

Hibernate Java

  1. #1
    Membre actif
    Inscrit en
    Juillet 2007
    Messages
    456
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 456
    Points : 231
    Points
    231
    Par défaut Hibernate + PostgerSQL
    Bonjour,
    J'essaye d'executer un petit programme hibernate, il permet de rajouter une ligne dans une table. J'ai pas d'erreur d'execution, mais rien ne se passe dans ma BD !!!!!!
    voila le log que Tomcat me retourne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    INFO: Server startup in 11719 ms
    INFO  - Hibernate 3.2.6 - org.hibernate.cfg.Environment  
    INFO  - hibernate.properties not found - org.hibernate.cfg.Environment  
    INFO  - Bytecode provider name : cglib - org.hibernate.cfg.Environment  
    INFO  - using JDK 1.4 java.sql.Timestamp handling - org.hibernate.cfg.Environment  
    INFO  - configuring from resource: /hibernate.cfg.xml - org.hibernate.cfg.Configuration  
    INFO  - Configuration resource: /hibernate.cfg.xml - org.hibernate.cfg.Configuration  
    INFO  - Reading mappings from resource : com/prototype/memberarea/mapping/Person.hbm.xml - org.hibernate.cfg.Configuration  
    INFO  - Mapping class: com.prototype.memberarea.mapping.Person -> person - org.hibernate.cfg.HbmBinder  
    INFO  - Configured SessionFactory: null - org.hibernate.cfg.Configuration  
    INFO  - Using Hibernate built-in connection pool (not for production use!) - org.hibernate.connection.DriverManagerConnectionProvider  
    INFO  - Hibernate connection pool size: 1 - org.hibernate.connection.DriverManagerConnectionProvider  
    INFO  - autocommit mode: false - org.hibernate.connection.DriverManagerConnectionProvider  
    INFO  - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost/bdTest - org.hibernate.connection.DriverManagerConnectionProvider  
    INFO  - connection properties: {user=postgres, password=****} - org.hibernate.connection.DriverManagerConnectionProvider  
    INFO  - RDBMS: PostgreSQL, version: 8.2.6 - org.hibernate.cfg.SettingsFactory  
    INFO  - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.3 JDBC3 with SSL (build 603) - org.hibernate.cfg.SettingsFactory  
    INFO  - Using dialect: org.hibernate.dialect.PostgreSQLDialect - org.hibernate.dialect.Dialect  
    INFO  - Using default transaction strategy (direct JDBC transactions) - org.hibernate.transaction.TransactionFactoryFactory  
    INFO  - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) - org.hibernate.transaction.TransactionManagerLookupFactory  
    INFO  - Automatic flush during beforeCompletion(): disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Automatic session close at end of transaction: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - JDBC batch size: 15 - org.hibernate.cfg.SettingsFactory  
    INFO  - JDBC batch updates for versioned data: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Scrollable result sets: enabled - org.hibernate.cfg.SettingsFactory  
    INFO  - JDBC3 getGeneratedKeys(): disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Connection release mode: auto - org.hibernate.cfg.SettingsFactory  
    INFO  - Default batch fetch size: 1 - org.hibernate.cfg.SettingsFactory  
    INFO  - Generate SQL with comments: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Order SQL updates by primary key: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Order SQL inserts for batching: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory - org.hibernate.cfg.SettingsFactory  
    INFO  - Using ASTQueryTranslatorFactory - org.hibernate.hql.ast.ASTQueryTranslatorFactory  
    INFO  - Query language substitutions: {} - org.hibernate.cfg.SettingsFactory  
    INFO  - JPA-QL strict compliance: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Second-level cache: enabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Query cache: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Cache provider: org.hibernate.cache.NoCacheProvider - org.hibernate.cfg.SettingsFactory  
    INFO  - Optimize cache for minimal puts: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Structured second-level cache entries: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Echoing all SQL to stdout - org.hibernate.cfg.SettingsFactory  
    INFO  - Statistics: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Deleted entity synthetic identifier rollback: disabled - org.hibernate.cfg.SettingsFactory  
    INFO  - Default entity-mode: pojo - org.hibernate.cfg.SettingsFactory  
    INFO  - Named query checking : enabled - org.hibernate.cfg.SettingsFactory  
    INFO  - building session factory - org.hibernate.impl.SessionFactoryImpl  
    INFO  - Not binding factory to JNDI, no JNDI name configured - org.hibernate.impl.SessionFactoryObjectFactory  
    INFO  - Running hbm2ddl schema export - org.hibernate.tool.hbm2ddl.SchemaExport  
    INFO  - exporting generated schema to database - org.hibernate.tool.hbm2ddl.SchemaExport  
    INFO  - schema export complete - org.hibernate.tool.hbm2ddl.SchemaExport  
    Hibernate: select nextval ('sequence_name')
    Hibernate: insert into person (firstname, lastname, address, phone, reference) values (?, ?, ?, ?, ?)
    mon fichier de conf est le suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <?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">ullink2008</property>
            <property name="hibernate.connection.url">jdbc:postgresql://localhost/bdTest</property>
            <property name="hibernate.connection.username">postgres</property>
            <property name="hibernate.connection.password"></property>
     
            <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
            <!-- Echo all executed SQL to stdout -->
            <property name="show_sql">true</property>
     
     
     
            <!-- Enable Hibernate's automatic session context management -->
            <property name="current_session_context_class">thread</property>
     
    		<!-- JDBC connection pool (use the built-in) -->
            <property name="connection.pool_size">1</property>
     
            <!-- Disable the second-level cache  -->
            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
     
            <!-- Drop and re-create the database schema on startup -->
            <property name="hbm2ddl.auto">create</property>	    
     
            <mapping resource="com/prototype/memberarea/mapping/Person.hbm.xml"/> 
     
        </session-factory>
    </hibernate-configuration>
    Merci pour votre aide

  2. #2
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    ce serait une bonne idée de poster le code en question...
    Nous les geeks, c'est pas qu'on a une case en moins, c'est juste qu'on compte à partir de zéro.
    Plus les choses changent, plus elles restent les mêmes

  3. #3
    Membre actif
    Inscrit en
    Juillet 2007
    Messages
    456
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 456
    Points : 231
    Points
    231
    Par défaut
    Le voila,
    mon bean Person
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    package com.prototype.memberarea.mapping;
     
    public class Person {
    	//	 reference number
        private int reference;
        // first name of the person
        private String firstname;
        // last name of the person
        private String lastname;
        // his adress
        private String address;
        // his phone
        private String phone;
     
        /**
         * Gets the adress of this person
         * @return reference number.
         */
    	public String getAddress() {
    		return address;
    	}
    	public void setAddress(String adress) {
    		this.address = adress;
    	}
     
        /**
         * Gets the phone number of this person
         * @return phone
         */
    	public String getPhone() {
    		return phone;
    	}
        /**
         * Sets the phone number of this person
         * @param phone number
         */
    	public void setPhone(String phone) {
    		this.phone = phone;
    	}
     
        /**
         * Gets the reference number of this person
         * @return reference number.
         */
    	public int getReference() {
    		return reference;
    	}
        /**
         * Sets the reference number of this person
         * @param refrence
         */
    	public void setReference(int reference) {
    		this.reference = reference;
    	}
     
    	/**
         * Creates a new instance of Data
         * @param reference reference number.
         * @param lastName last name of the person
         * @param firstName first name of the person
         * @param phone his phone number.
         * @param adress the adress of the person
         */
    	public Person(int reference, String lastName, String firstName, String adress, String phone) {
    		this.reference = reference;
    		this.firstname = firstName;
    		this.lastname = lastName;
    		this.address = adress;
    		this.phone = phone;
    	}
    	public String getFirstname() {
    		return firstname;
    	}
    	public void setFirstname(String firstname) {
    		this.firstname = firstname;
    	}
    	public String getLastname() {
    		return lastname;
    	}
    	public void setLastname(String lastname) {
    		this.lastname = lastname;
    	}
     
    	public Person() {
     
    	}
    }
    mon fichier hbm
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    <?xml version="1.0"?>
                <!DOCTYPE hibernate-mapping PUBLIC
                    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
     
                <hibernate-mapping>
                    <class name="com.prototype.memberarea.mapping.Person" table="person">
                        <id name="reference" column="reference">
                            <generator class="native"/>
     
                        </id>
     
                        <property name="firstname" column="firstname"/>
                        <property name="lastname" column="lastname"/>
                        <property name="address" column="address"/>
                        <property name="phone" column="phone"/>
     
                    </class>
     
                </hibernate-mapping>
    et pour l'executer j'utilise se bout de code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
            session.beginTransaction();
     
            Person s = new Person(10, "fff", "fffss", "Paris", "00000");
            session.save(s);
     
            session.getTransaction().commit();
    et voila merci

  4. #4
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    hum je ne vois pas la déclaration du gestionnaire de transactions dans ton hibernate.cfg.xml

    peux-tu réessayer en rajoutant ce code ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <property name="hibernate.transaction.factory_class">
         org.hibernate.transaction.JDBCTransactionFactory
    </property>
    Nous les geeks, c'est pas qu'on a une case en moins, c'est juste qu'on compte à partir de zéro.
    Plus les choses changent, plus elles restent les mêmes

  5. #5
    Membre actif
    Inscrit en
    Juillet 2007
    Messages
    456
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 456
    Points : 231
    Points
    231
    Par défaut
    merci pour ta réponse,
    J'ai rajouté la propriété que tu m'a passé, mais hélas ça marche tjrs pas

  6. #6
    Membre éprouvé Avatar de Gardyen
    Homme Profil pro
    Bio informaticien
    Inscrit en
    Août 2005
    Messages
    637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 44
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Bio informaticien

    Informations forums :
    Inscription : Août 2005
    Messages : 637
    Points : 1 050
    Points
    1 050
    Par défaut
    hum il y a 2 mots de passe dans ton fichier de config ?
    ul... et un vide, dégage le vide et essaye encore
    Nous les geeks, c'est pas qu'on a une case en moins, c'est juste qu'on compte à partir de zéro.
    Plus les choses changent, plus elles restent les mêmes

  7. #7
    Membre actif
    Inscrit en
    Juillet 2007
    Messages
    456
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 456
    Points : 231
    Points
    231
    Par défaut
    j'ai remarque ça, j'ai oublié de le signaler ici. Mais ca marche pas.
    Je viens d'essayer le même code avec une bd Mysql, ça marche sans aucun probleme. bizar !!!

  8. #8
    Membre actif
    Inscrit en
    Juillet 2007
    Messages
    456
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 456
    Points : 231
    Points
    231
    Par défaut
    voila ce qui change
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
            <property name="connection.url">jdbc:mysql://localhost/dbTest</property>
            <property name="connection.username">root</property>
            <property name="connection.password"></property>
            <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>

  9. #9
    Membre actif
    Inscrit en
    Juillet 2007
    Messages
    456
    Détails du profil
    Informations forums :
    Inscription : Juillet 2007
    Messages : 456
    Points : 231
    Points
    231
    Par défaut
    Salut,
    Je viens de voir l'erreur, au faite c'est au niveau de ma BD, j'avais pas le droit d'y accéder. Une erreur de débutant
    Merci Gardyen

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Hibernate] Problemes de connexion d'un sous domaine
    Par sylvain_neus dans le forum Hibernate
    Réponses: 15
    Dernier message: 09/05/2006, 10h49
  2. [Stratégie]JDBC ou Hibernate
    Par yanis97 dans le forum JDBC
    Réponses: 3
    Dernier message: 03/12/2004, 16h23
  3. [Plugin] Hibernate
    Par speedster dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 26/08/2004, 11h01
  4. Fonctionnement d'Hibernate
    Par coyot dans le forum Hibernate
    Réponses: 12
    Dernier message: 19/05/2004, 19h10
  5. [JDO]Hibernate : Mapping d'un champ auto-incrémenté
    Par brice.antoine dans le forum Hibernate
    Réponses: 4
    Dernier message: 02/04/2004, 10h36

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo