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 :

problème avec la persistance des objets


Sujet :

Hibernate Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut problème avec la persistance des objets
    Bonjour tout le monde,

    Je travaille à partir d'un tutoriel pour apprendre hibernate, c'est le tutoriel de julien DEFAUT.

    J'ai suivi methodiquement, j'ai configuré correctement hibernate.

    Mais lors de la compilation de cette page j'ai cette erreur qui est générée:
    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
    3 avr. 2007 11:33:50 net.sf.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 2.1.6
    3 avr. 2007 11:33:50 net.sf.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    3 avr. 2007 11:33:50 net.sf.hibernate.cfg.Environment <clinit>
    INFO: using CGLIB reflection optimizer
    3 avr. 2007 11:33:50 net.sf.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    3 avr. 2007 11:33:50 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-many association mappings
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-one association property references
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing foreign key constraints
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
    ATTENTION: No dialect set - using GenericDialect: Dialect class not found: org.hibernate.dialect.MySQLDialect
    3 avr. 2007 11:33:52 net.sf.hibernate.dialect.Dialect <init>
    INFO: Using dialect: net.sf.hibernate.dialect.GenericDialect
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use outer join fetching: true
    3 avr. 2007 11:33:52 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    3 avr. 2007 11:33:52 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 20
    3 avr. 2007 11:33:52 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/Base1
    3 avr. 2007 11:33:52 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=root}
    3 avr. 2007 11:33:52 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use scrollable result sets: true
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use JDBC3 getGeneratedKeys(): true
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: false
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
    3 avr. 2007 11:33:52 net.sf.hibernate.cfg.Configuration configureCaches
    INFO: instantiating and configuring caches
    3 avr. 2007 11:33:53 net.sf.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    3 avr. 2007 11:33:56 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    Exception in thread "main" net.sf.hibernate.MappingException: No persister for: com.minosis.hibernate.TContact
    	at net.sf.hibernate.impl.SessionFactoryImpl.getPersister(SessionFactoryImpl.java:347)
    	at net.sf.hibernate.impl.SessionImpl.getClassPersister(SessionImpl.java:2690)
    	at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2697)
    	at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:763)
    	at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738)
    	at Test.main(Test.java:16)
    Le code que je compile est celui ci:
    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
     
    import net.sf.hibernate.*;
    import com.minosis.hibernate.*;
    import com.minosis.bdd.*;
    public class Test {
     
    public static void main(String[] args) throws HibernateException
    {
    	Session session=HibernateUtil.currentSession();
    	Transaction tx=session.beginTransaction();
     
    	TContact contact=new TContact();
    	contact.setNom("Dupont");
    	contact.setPrenom("Jean");
    	contact.setAge(new Integer(33));
    	session.save(contact);
    /*	
    	contact=new TContact();
    	contact.setNom("Lambert");
    	contact.setPrenom("Julie");
    	contact.setAge(new Integer(27));
    	session.save(contact);
    */
    	tx.commit();
    	HibernateUtil.closeSession();
    }
    }
    Je vous remercie de votre aide

  2. #2
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Apparement il te dit que tu n'as pas creer cette classe :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    com.minosis.hibernate.TContact
    As-tu creer la classe TContact?
    As-tu creer le mapping?
    L'as-tu ecris dans ton fichier de configuration?

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je te remercie de ta réponse aussi rapide.

    J'ai bien créé la classe TContact, elle fait partie du package com.minosis.hibernate.

    Je te donne le code:
    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
    package com.minosis.hibernate;
     
    import com.minosis.hibernate.base.BaseTContact;
     
    /**
     * This is the object class that relates to the t_contact table.
     * Any customizations belong here.
     */
    public class TContact extends BaseTContact {
     
    /*[CONSTRUCTOR MARKER BEGIN]*/
    	public TContact () {
    		super();
    	}
     
    	/**
             * Constructor for primary key
             */
    	public TContact (java.lang.Integer _id) {
    		super(_id);
    	}
     
    /*[CONSTRUCTOR MARKER END]*/
    }
    J'ai bien créé mon mapping:
    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
    <?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.minosis.hibernate.TContact" table="t_contact">
     <id name="id" type="integer">
      <column name="id" sql-type="int(11)"/>
      <generator class="increment"/>
     </id>
     <property name="Nom" type="string">
      <column name="nom" sql-type="varchar(50)" not-null="true"/>
     </property>
     <property name="Prenom" type="string">
      <column name="prenom" sql-type="varchar(50)" not-null="true"/>
     </property>
     <property name="Age" type="integer">
      <column name="age" sql-type="int(11)" not-null="true"/>
     </property>
     </class>
    </hibernate-mapping>
    J'ai bien créé mon fichier de configuration le voici:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?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.gjt.mm.mysql.Driver</property>
            <property name="hibernate.connection.url">jdbc:mysql://localhost/Base1</property>
            <property name="hibernate.connection.username">root</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        </session-factory>
    </hibernate-configuration>


    NB:J'utilise le SGBDR MySQL et le nom de la base de données est Base1

    Je vous remercie de votre aide.

  4. #4
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Il te faut definir chacun des mappings dans le fichier de configuration

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <mapping resource="la_ou_tu_l_as_range/TContact.hbm.xml"/>
    Jette un oeil sur la doc, tu comprendras certaines choses
    http://www.hibernate.org/hib_docs/v3...iguration.html

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je te remercie de ton aide.

    Je voudrais savoir, je mets ce bout de code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     <mapping resource="TContact.hbm.xml"/>
    dans ce fichier là?:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <?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.gjt.mm.mysql.Driver</property>
            <property name="hibernate.connection.url">jdbc:mysql://localhost/base1</property>
            <property name="hibernate.connection.username">root</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        </session-factory>
     
    </hibernate-configuration>
    Si oui à quel emplacement, car là je viens de le mettre après le tag sessionfactory est la il a des erreurs.

    NB:mon fichier "TContact.hbm.xml" est dans le scr
    Je vous remercie de votre aide

  6. #6
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je voualis vous dire que j'ai résoulu le problème, il m'a bien rentré dans la base les infos.

    Au niveau du fichier de configuration XML, le voici:
    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
     
    <?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.gjt.mm.mysql.Driver</property>
            <property name="hibernate.connection.url">jdbc:mysql://localhost/base1</property>
            <property name="hibernate.connection.username">root</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <mapping resource="TContact.hbm.xml"/> 
        </session-factory>
    </hibernate-configuration>
    Je vous remercie de votre aide.

    Mais lorsque je compile, j'ai des erreurs qui s'affiche
    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
    3 avr. 2007 14:23:01 net.sf.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 2.1.6
    3 avr. 2007 14:23:01 net.sf.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    3 avr. 2007 14:23:01 net.sf.hibernate.cfg.Environment <clinit>
    INFO: using CGLIB reflection optimizer
    3 avr. 2007 14:23:01 net.sf.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    3 avr. 2007 14:23:01 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    3 avr. 2007 14:23:03 net.sf.hibernate.cfg.Configuration addResource
    INFO: Mapping resource: TContact.hbm.xml
    3 avr. 2007 14:23:06 net.sf.hibernate.cfg.Binder bindRootClass
    INFO: Mapping class: com.minosis.hibernate.TContact -> t_contact
    3 avr. 2007 14:23:06 net.sf.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    3 avr. 2007 14:23:06 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-many association mappings
    3 avr. 2007 14:23:06 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-one association property references
    3 avr. 2007 14:23:06 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing foreign key constraints
    3 avr. 2007 14:23:06 net.sf.hibernate.cfg.SettingsFactory buildSettings
    ATTENTION: No dialect set - using GenericDialect: Dialect class not found: org.hibernate.dialect.MySQLDialect
    3 avr. 2007 14:23:06 net.sf.hibernate.dialect.Dialect <init>
    INFO: Using dialect: net.sf.hibernate.dialect.GenericDialect
    3 avr. 2007 14:23:06 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use outer join fetching: true
    3 avr. 2007 14:23:06 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    3 avr. 2007 14:23:06 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 20
    3 avr. 2007 14:23:06 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/base1
    3 avr. 2007 14:23:06 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=root}
    3 avr. 2007 14:23:06 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    3 avr. 2007 14:23:09 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use scrollable result sets: true
    3 avr. 2007 14:23:09 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use JDBC3 getGeneratedKeys(): true
    3 avr. 2007 14:23:09 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: false
    3 avr. 2007 14:23:09 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    3 avr. 2007 14:23:09 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
    3 avr. 2007 14:23:09 net.sf.hibernate.cfg.Configuration configureCaches
    INFO: instantiating and configuring caches
    3 avr. 2007 14:23:09 net.sf.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    3 avr. 2007 14:23:12 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    je voudrais savoir comment ca se fait.

    Je vous remercie de votre aide

  7. #7
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Je ne vois pas d'erreur dans les messages que tu m'as passé.
    ce sont juste des messages d'information.

    ce que tu as fait me parait correct.

    Parviens-tu a ecrire Jean Dupont dans la base de donnees?
    Si oui c est que cela fonctionne.

  8. #8
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je te remercie.

    Je parviens à écrire Jean Dupont dans la base de données mais par contre je ne parviens pas à le récupérer avec une requete SQL.

    J'ai une question les requete SQL, il faut les écrire dans le fichier mapping car moi j'ai écris directement dans Test.Java car dans le tutoriel c'est là où il a écrit mais j'ai vu dans le forum, il a des personnes qui écrive dans le fichier mapping.

    Je te montre mon code Test.java:
    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
     
     
     
     
     
    import java.util.Iterator;
     
     
    import net.sf.hibernate.*;
     
     
     
    import com.minosis.hibernate.*;
    import com.minosis.bdd.*;
    import net.sf.hibernate.Query;
    public class Test {
     
    public static void main(String[] args) throws HibernateException
    {
     
    	Session session=(Session)HibernateUtil.currentSession();
     
    	Iterator list=(Iterator)session.find("Select * FROM t_contact WHERE nom like '%t'");
     
    	while(list.hasNext())
    	{
    		TContact uncontact=(TContact) list.next();
    		System.out.println(uncontact.getAge());
    	}
     
     
    }
    }
    Les erreurs qui me sont générées sont les suivantes:
    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
    3 avr. 2007 16:22:51 net.sf.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 2.1.6
    3 avr. 2007 16:22:51 net.sf.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    3 avr. 2007 16:22:51 net.sf.hibernate.cfg.Environment <clinit>
    INFO: using CGLIB reflection optimizer
    3 avr. 2007 16:22:51 net.sf.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    3 avr. 2007 16:22:51 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    3 avr. 2007 16:22:52 net.sf.hibernate.cfg.Configuration addResource
    INFO: Mapping resource: TContact.hbm.xml
    3 avr. 2007 16:22:55 net.sf.hibernate.cfg.Binder bindRootClass
    INFO: Mapping class: com.minosis.hibernate.TContact -> t_contact
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-many association mappings
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-one association property references
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing foreign key constraints
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.SettingsFactory buildSettings
    ATTENTION: No dialect set - using GenericDialect: Dialect class not found: org.hibernate.dialect.MySQLDialect
    3 avr. 2007 16:22:56 net.sf.hibernate.dialect.Dialect <init>
    INFO: Using dialect: net.sf.hibernate.dialect.GenericDialect
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use outer join fetching: true
    3 avr. 2007 16:22:56 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    3 avr. 2007 16:22:56 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 20
    3 avr. 2007 16:22:56 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/base1
    3 avr. 2007 16:22:56 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=root}
    3 avr. 2007 16:22:56 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use scrollable result sets: true
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use JDBC3 getGeneratedKeys(): true
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: false
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
    3 avr. 2007 16:22:56 net.sf.hibernate.cfg.Configuration configureCaches
    INFO: instantiating and configuring caches
    3 avr. 2007 16:22:56 net.sf.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    3 avr. 2007 16:22:57 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    Exception in thread "main" net.sf.hibernate.QueryException: * only allowed inside aggregate function in SELECT [Select * FROM t_contact WHERE nom like '%t']
    	at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:114)
    	at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
    	at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
    	at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
    	at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
    	at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
    	at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
    	at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
    	at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
    	at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
    	at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1521)
    	at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1513)
    	at Test.main(Test.java:23)
    Je vous remercie de votre aide

  9. #9
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    il te faut utiliser createQuery ou createSqlQuery

    Jette un oeil ici :
    http://www.hibernate.org/hib_docs/v3...ying-executing

  10. #10
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je te remercie de ton aide.

    Je suis en train de regarder par conséquent si je comprend bien, il ne faut pas coder les requetes sql dans le mapping alors.

    Je vous remercie

  11. #11
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je te remercie encore de ton aide.

    J'ai modifier mon code mais des erreurs résides, visiblement il veut pas que je fasse des select .

    Voici mon message d'erreur qui est généré:
    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
    3 avr. 2007 18:01:30 net.sf.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 2.1.6
    3 avr. 2007 18:01:30 net.sf.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    3 avr. 2007 18:01:30 net.sf.hibernate.cfg.Environment <clinit>
    INFO: using CGLIB reflection optimizer
    3 avr. 2007 18:01:30 net.sf.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    3 avr. 2007 18:01:30 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    3 avr. 2007 18:01:31 net.sf.hibernate.cfg.Configuration addResource
    INFO: Mapping resource: TContact.hbm.xml
    3 avr. 2007 18:01:34 net.sf.hibernate.cfg.Binder bindRootClass
    INFO: Mapping class: com.minosis.hibernate.TContact -> t_contact
    3 avr. 2007 18:01:35 net.sf.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    3 avr. 2007 18:01:35 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-many association mappings
    3 avr. 2007 18:01:35 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-one association property references
    3 avr. 2007 18:01:35 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing foreign key constraints
    3 avr. 2007 18:01:35 net.sf.hibernate.cfg.SettingsFactory buildSettings
    ATTENTION: No dialect set - using GenericDialect: Dialect class not found: org.hibernate.dialect.MySQLDialect
    3 avr. 2007 18:01:35 net.sf.hibernate.dialect.Dialect <init>
    INFO: Using dialect: net.sf.hibernate.dialect.GenericDialect
    3 avr. 2007 18:01:35 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use outer join fetching: true
    3 avr. 2007 18:01:35 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    3 avr. 2007 18:01:35 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 20
    3 avr. 2007 18:01:35 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/base1
    3 avr. 2007 18:01:35 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=root}
    3 avr. 2007 18:01:35 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    3 avr. 2007 18:01:39 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use scrollable result sets: true
    3 avr. 2007 18:01:39 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use JDBC3 getGeneratedKeys(): true
    3 avr. 2007 18:01:39 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: false
    3 avr. 2007 18:01:39 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    3 avr. 2007 18:01:39 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
    3 avr. 2007 18:01:39 net.sf.hibernate.cfg.Configuration configureCaches
    INFO: instantiating and configuring caches
    3 avr. 2007 18:01:39 net.sf.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    3 avr. 2007 18:01:42 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    Exception in thread "main" net.sf.hibernate.QueryException: * only allowed inside aggregate function in SELECT [SELECT * FROM t_contact]
    	at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:114)
    	at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
    	at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
    	at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
    	at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
    	at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
    	at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
    	at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
    	at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
    	at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1592)
    	at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:27)
    	at Test.main(Test.java:24)
    Je vous donne égallement le code que j'ai généré:
    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
     
     
     
     
     
     
    import java.util.Iterator;
     
     
    import net.sf.hibernate.*;
     
     
     
    import com.minosis.hibernate.*;
    import com.minosis.bdd.*;
    import net.sf.hibernate.Query;
    public class Test {
     
    public static void main(String[] args) throws HibernateException
    {
     
    	Session session=(Session)HibernateUtil.currentSession();
    	Transaction tx = session.beginTransaction();
    	Iterator list= session.createQuery("SELECT * FROM t_contact").iterate();
     
     
    	while(list.hasNext())
    	{
    		TContact uncontact=(TContact) list.next();
    		System.out.println(uncontact.getAge());
    	}
     
     
    }
    }
    Je vous remercie de votre aide

  12. #12
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    createQuery prends la syntaxe HQL
    createSQLQuery prends la syntaxe SQL

    Tu as ecris une syntaxe SQL dans createQuery.

  13. #13
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je te remercie, j'ai opté pour la methode createsqlquery

    L'erreur qui met générée est celle-ci:

    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
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    3 avr. 2007 21:23:08 net.sf.hibernate.cfg.Environment <clinit>
    INFO: Hibernate 2.1.6
    3 avr. 2007 21:23:08 net.sf.hibernate.cfg.Environment <clinit>
    INFO: hibernate.properties not found
    3 avr. 2007 21:23:08 net.sf.hibernate.cfg.Environment <clinit>
    INFO: using CGLIB reflection optimizer
    3 avr. 2007 21:23:08 net.sf.hibernate.cfg.Configuration configure
    INFO: configuring from resource: /hibernate.cfg.xml
    3 avr. 2007 21:23:08 net.sf.hibernate.cfg.Configuration getConfigurationInputStream
    INFO: Configuration resource: /hibernate.cfg.xml
    3 avr. 2007 21:23:10 net.sf.hibernate.cfg.Configuration addResource
    INFO: Mapping resource: TContact.hbm.xml
    3 avr. 2007 21:23:13 net.sf.hibernate.cfg.Binder bindRootClass
    INFO: Mapping class: com.minosis.hibernate.TContact -> t_contact
    3 avr. 2007 21:23:13 net.sf.hibernate.cfg.Configuration doConfigure
    INFO: Configured SessionFactory: null
    3 avr. 2007 21:23:13 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-many association mappings
    3 avr. 2007 21:23:13 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing one-to-one association property references
    3 avr. 2007 21:23:13 net.sf.hibernate.cfg.Configuration secondPassCompile
    INFO: processing foreign key constraints
    3 avr. 2007 21:23:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    ATTENTION: No dialect set - using GenericDialect: Dialect class not found: org.hibernate.dialect.MySQLDialect
    3 avr. 2007 21:23:13 net.sf.hibernate.dialect.Dialect <init>
    INFO: Using dialect: net.sf.hibernate.dialect.GenericDialect
    3 avr. 2007 21:23:13 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use outer join fetching: true
    3 avr. 2007 21:23:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Using Hibernate built-in connection pool (not for production use!)
    3 avr. 2007 21:23:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: Hibernate connection pool size: 20
    3 avr. 2007 21:23:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: using driver: org.gjt.mm.mysql.Driver at URL: jdbc:mysql://localhost/base1
    3 avr. 2007 21:23:13 net.sf.hibernate.connection.DriverManagerConnectionProvider configure
    INFO: connection properties: {user=root}
    3 avr. 2007 21:23:13 net.sf.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    INFO: No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
    3 avr. 2007 21:23:14 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use scrollable result sets: true
    3 avr. 2007 21:23:14 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Use JDBC3 getGeneratedKeys(): true
    3 avr. 2007 21:23:14 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Optimize cache for minimal puts: false
    3 avr. 2007 21:23:14 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: Query language substitutions: {}
    3 avr. 2007 21:23:14 net.sf.hibernate.cfg.SettingsFactory buildSettings
    INFO: cache provider: net.sf.hibernate.cache.EhCacheProvider
    3 avr. 2007 21:23:14 net.sf.hibernate.cfg.Configuration configureCaches
    INFO: instantiating and configuring caches
    3 avr. 2007 21:23:14 net.sf.hibernate.impl.SessionFactoryImpl <init>
    INFO: building session factory
    3 avr. 2007 21:23:15 net.sf.hibernate.impl.SessionFactoryObjectFactory addInstance
    INFO: Not binding factory to JNDI, no JNDI name configured
    3 avr. 2007 21:23:15 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
    ATTENTION: SQL Error: 0, SQLState: S0022
    3 avr. 2007 21:23:15 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
    GRAVE: Column 'id0_' not found.
    3 avr. 2007 21:23:15 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
    ATTENTION: SQL Error: 0, SQLState: S0022
    3 avr. 2007 21:23:15 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
    GRAVE: Column 'id0_' not found.
    3 avr. 2007 21:23:15 net.sf.hibernate.JDBCException <init>
    GRAVE: SQLException occurred
    java.sql.SQLException: Column 'id0_' not found.
    	at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
    	at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
    	at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
    	at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
    	at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
    	at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:427)
    	at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:200)
    	at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
    	at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
    	at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
    	at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
    	at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
    	at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
    	at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
    	at Test.main(Test.java:24)
    Exception in thread "main" net.sf.hibernate.JDBCException: SQLException occurred
    	at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3809)
    	at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
    	at Test.main(Test.java:24)
    Caused by: java.sql.SQLException: Column 'id0_' not found.
    	at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2317)
    	at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
    	at net.sf.hibernate.type.IntegerType.get(IntegerType.java:18)
    	at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
    	at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
    	at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:427)
    	at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:200)
    	at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
    	at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
    	at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
    	at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
    	at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
    	at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3806)
    	... 2 more
    Le code que j'ai généré est celui-ci:


    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
     
    import java.util.Iterator;
     
     
    import net.sf.hibernate.*;
     
     
     
    import com.minosis.hibernate.*;
    import com.minosis.bdd.*;
    import net.sf.hibernate.Query;
    public class Test {
     
    public static void main(String[] args) throws HibernateException
    {
     
    	Session session=(Session)HibernateUtil.currentSession();
    	Transaction tx = session.beginTransaction();
    	Iterator list = session.createSQLQuery("select *  FROM t_contact","t_contact",TContact.class).list().listIterator();
    	while(list.hasNext())
    	{
    		TContact uncontact=(TContact) list.next();
    		System.out.println(uncontact.getAge());
    	}
     
     
    }
    }
    Dans ma base de donnée, je n'ai pas de champ "'id0_", ce ne compred pas pourquoi il me demande ce champ.

    Je vous remercie de votre aide

  14. #14
    Membre expérimenté Avatar de willoi
    Profil pro
    Développeur informatique
    Inscrit en
    Décembre 2006
    Messages
    1 355
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 1 355
    Points : 1 639
    Points
    1 639
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Iterator  it= session.createSQLQuery("select *  FROM t_contact").list().iterator();
    A mon avis ceci est largement suffisant.(la syntaxe que tu utilises est deprecated)
    Mais ca me parait plus simple en faisant la syntaxe HQL :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    Iterator  it= session.createSQLQuery("FROM TContact").list().iterator();
    	while(it.hasNext())
    	{
    		TContact uncontact=(TContact) it.next();
    		System.out.println(uncontact.getAge());
    	}

  15. #15
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    172
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 172
    Points : 60
    Points
    60
    Par défaut
    Je te remercie de ton aide.

    J'avais réussi avec la methode createSQLQuery mais je vais utiliser la methode que tu me dis car la mienne est obsolete.

    Sinon avec la methode HQL, comment sélectionner certains champs, car on ne peut pas faire "select nom, prenom" par exemple.


    Sinon j'ai ouvert une autre discussion afin de savoir si j'ai bien assimilé ces nouvelles notions.

    Je te remercie de ton aide

  16. #16
    Membre du Club
    Inscrit en
    Juin 2005
    Messages
    45
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 45
    Points : 42
    Points
    42
    Par défaut cool
    Citation Envoyé par gentil
    Je te remercie de ton aide.

    J'avais réussi avec la methode createSQLQuery mais je vais utiliser la methode que tu me dis car la mienne est obsolete.

    Sinon avec la methode HQL, comment sélectionner certains champs, car on ne peut pas faire "select nom, prenom" par exemple.


    Sinon j'ai ouvert une autre discussion afin de savoir si j'ai bien assimilé ces nouvelles notions.

    Je te remercie de ton aide
    bonjour gentil, est ce que tu peu m'indiqué le tutorial que ta suivie, merci
    c cool, que ta pu faire marché hibernate
    a+

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

Discussions similaires

  1. Réponses: 0
    Dernier message: 11/10/2012, 18h35
  2. Réponses: 14
    Dernier message: 04/10/2012, 13h14
  3. Réponses: 10
    Dernier message: 10/10/2009, 18h39
  4. [Problèmes avec ArrayList] Supprimer des objets égaux à null
    Par smutmutant2003 dans le forum Collection et Stream
    Réponses: 5
    Dernier message: 08/10/2009, 10h43
  5. Réponses: 11
    Dernier message: 16/12/2003, 19h58

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