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 :

mapping et entity class not found


Sujet :

Hibernate Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut mapping et entity class not found
    Bonjour,

    je reviens avec une autre question concernant le mapping. Le sujet a déja été résolu par le passé, mais la réponse n'est pas écrit dans le topic en question. j'y vais donc... j'ai le fichier de config comme ca :

    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
     
    <?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.hsqldb.jdbcDriver</property>
            <property name="hibernate.connection.url">jdbc:hsqldb:/home/yannmauron/toxico_db</property>
            <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
     
     
            <!-- JDBC connection pool (use the built-in) -->
            <property name="connection.pool_size">1</property>
     
     
            <!-- Enable Hibernate's automatic session context management -->
            <property name="current_session_context_class">thread</property>
     
            <!-- Disable the second-level cache  -->
            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
     
            <!-- Echo all executed SQL to stdout -->
            <property name="show_sql">true</property>
     
        </session-factory>
    </hibernate-configuration>
    le fichier de 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
     
    <?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 package="com.genebio.toxico.compound">
        <class name="CompoundImpl" table="COMPOUND">
            <id name="id" type="int" column="COMPOUND_ID">
            </id>
            <property name="cid" type="string" column="COMPOUND_CID"/>
            <property name="SMILE" type="string" column="COMPOUND_SMILE"/>
     
        </class>
    </hibernate-mapping>
    Dans ma logique ca devrait marcher pourtant la console me réponde :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    org.hibernate.MappingException: entity class not found: com.genebio.toxico.compound.CompoundImpl
      org.hibernate.MappingException: entity class not found: com.genebio.toxico.compound.CompoundImpl
      java.lang.ClassNotFoundException: com.genebio.toxico.compound.CompoundImpl
    Pourtant j'ai bien une architecture du genre :

    src
    ->config.cfg.xml
    ->com.genebio.toxico.compound
    ->->CompoundImpl.java
    ->->CompoundImpl.hbm.xml


    Donc ca devrait marcher non ?

  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
    Ta classe CompoundImpl est correctement compilee ?

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    oui... build successfull...

    si jamais ma classe CompoundImpl ressemble à :

    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
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
     
    package com.genebio.toxico.compound;
     
    /**
     * Basic class for the compound object
     * 
     * @author Yann
     *
     */
     
    import java.util.ArrayList;
    import java.io.Serializable;
     
    public class CompoundImpl extends CompoundImplBase implements Serializable{
     
    	protected String cid;
    	protected int id;
    	protected String SMILE;
    	protected ArrayList<CompoundDescriptor> compoundDescriptors;
    	protected ArrayList<CompoundName> compoundNames;
    	protected ArrayList<CompoundClassification> compoundclassification;
    	protected ArrayList<CompoundCorrelation> compoundcorrelations;
    	protected ArrayList<CompoundXref> compoundXrefs;
     
    	//minimum information for a compound
    	public CompoundImpl(int id, String cid, String SMILE){
    		this.id 					= id;
    		this.cid 					= cid;
    		this.SMILE 					= SMILE;	
    	}
     
    	//primary information for a compound
    	public CompoundImpl(int id, String cid, String SMILE, 
    			ArrayList<CompoundDescriptor> compoundDescriptors, 
    			ArrayList<CompoundName> compoundNames, 
    			ArrayList<CompoundXref> compoundXrefs
    			){
     
    		this.id 					= id;
    		this.cid 					= cid;
    		this.SMILE 					= SMILE;
    		this.compoundDescriptors	= compoundDescriptors;
    		this.compoundNames			= compoundNames;
    		this.compoundXrefs			= compoundXrefs;
    }
     
    	//future information for a compound (correlation and classification informations are added)
    	public CompoundImpl(int id, String cid, String SMILE, 
    					ArrayList<CompoundDescriptor> compoundDescriptors, 
    					ArrayList<CompoundName> compoundNames, 
    					ArrayList<CompoundXref> compoundXrefs,
    					ArrayList<CompoundClassification> compoundclassification, 
    					ArrayList<CompoundCorrelation> compoundcorrelations 
    					){
     
    		this.id 					= id;
    		this.cid 					= cid;
    		this.SMILE 					= SMILE;
    		this.compoundclassification	= compoundclassification;
    		this.compoundcorrelations	= compoundcorrelations;
    		this.compoundDescriptors	= compoundDescriptors;
    		this.compoundNames			= compoundNames;
    		this.compoundXrefs			= compoundXrefs;
    	}
     
     
    	public String getSMILE(){
    		return SMILE;
    	}
     
    	public ArrayList<CompoundClassification> getCompoundclassification() {
    		return compoundclassification;
    	}
     
    	public void setCompoundclassification(
    			ArrayList<CompoundClassification> compoundclassification) {
    		this.compoundclassification = compoundclassification;
    	}
     
    	public ArrayList<CompoundCorrelation> getCompoundcorrelations() {
    		return compoundcorrelations;
    	}
     
    	public void setCompoundcorrelations(
    			ArrayList<CompoundCorrelation> compoundcorrelations) {
    		this.compoundcorrelations = compoundcorrelations;
    	}
     
    	public ArrayList<CompoundDescriptor> getCompoundDescriptors() {
    		return compoundDescriptors;
    	}
     
    	public void setCompoundDescriptors(
    			ArrayList<CompoundDescriptor> compoundDescriptors) {
    		this.compoundDescriptors = compoundDescriptors;
    	}
     
    	public ArrayList<CompoundName> getCompoundNames() {
    		return compoundNames;
    	}
     
    	public void setCompoundNames(ArrayList<CompoundName> compoundNames) {
    		this.compoundNames = compoundNames;
    	}
     
    	public ArrayList<CompoundXref> getCompoundXrefs() {
    		return compoundXrefs;
    	}
     
    	public void setCompoundXrefs(ArrayList<CompoundXref> compoundXrefs) {
    		this.compoundXrefs = compoundXrefs;
    	}
     
    	public int getId() {
    		return id;
    	}
     
    	public String getCid() {
    		return cid;
    	}
     
    }
    sans erreur...

  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
    Peut etre creer un constructeur vide.

    selon la doc paragraphe 4.1.1. Implémenter un constructeur sans argument:

    http://www.hibernate.org/hib_docs/v3...t-classes.html

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    It was a good idea, but it still doesn't work...

  6. #6
    Membre expérimenté Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Points : 1 371
    Points
    1 371
    Par défaut
    Essaye en mettant ceci :

    dans ton fichier de config hibernate :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <mapping resource="com/genebio/toxico/compound/CompoundImpl.hbm.xml" />
    Sinon pour le constructeur vide, il faut l'avoir pour que Hibernate puisse crée une instance de ta classe. C'est l'erreur que t'aurais juste après avoir résolu celle que tu as en ce moment!

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    Okay, merci pour la réponse... en fait j'ai un peu contourné le plugin du coup en mettant en place un applicationcontext...

    Mais a partir de la j'ai le problème que je met dans mon post d'apres. Ca avance gentillement mais surement ;-)

  8. #8
    Membre expérimenté Avatar de maxf1
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Âge : 39
    Localisation : France, Moselle (Lorraine)

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 229
    Points : 1 371
    Points
    1 371
    Par défaut
    Citation Envoyé par mauroyb0
    Okay, merci pour la réponse... en fait j'ai un peu contourné le plugin du coup en mettant en place un applicationcontext...

    Mais a partir de la j'ai le problème que je met dans mon post d'apres. Ca avance gentillement mais surement ;-)

    pas tout suivi la? Ta fait ce que je t'ai dit? Ca ne marché pas simplement avec ca?
    Tu as ouvert un autre post?

  9. #9
    Membre du Club
    Profil pro
    Inscrit en
    Mars 2006
    Messages
    111
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Mars 2006
    Messages : 111
    Points : 44
    Points
    44
    Par défaut
    En fait oui ca a marché. L'opération d'après, c'est que j'ai tout transféré en spring ave un applicationContext et tout et tout...

    A partir de la, j'ai un autre soucis, je n'arrive pas a faire d'entrée dans ma base, un peu comme si il n'y avait pas de comit... pourtant mon applicationContext est défini comme ca :

    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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
        "http://www.springframework.org/dtd/spring-beans.dtd">
     
    <beans>
     
     <!-- Hibernate data source -->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>org.hsqldb.jdbcDriver</value></property>
             <property name="url"><value>jdbc:hsqldb:/home/yannmauron/toxico_db</value></property>
            <property name="username"><value>sa</value></property>
            <property name="password"><value></value></property>
        </bean>
     
     
     <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
         <property name="dataSource"><ref local="dataSource"/></property>
        <property name="mappingResources">
            <list>
                <value>com/genebio/toxico/compound/CompoundImpl.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">update</prop>
        </props>
        </property>
    </bean>
     
    <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory"><ref local="sessionFactory"/></property>
    </bean>
     
    <bean id="CompoundDAO" class="com.genebio.toxico.compound.CompoundDAOImpl">
            <property name="sessionFactory"><ref local="sessionFactory"/></property>
        </bean>
     
     
    </beans>

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

Discussions similaires

  1. [Mapping] Erreur "Entity class not found"
    Par yo_haha dans le forum Hibernate
    Réponses: 2
    Dernier message: 17/12/2011, 19h14
  2. [Mapping] Erreur "entity class not found"
    Par SpeedOverflow dans le forum Hibernate
    Réponses: 6
    Dernier message: 20/10/2011, 16h12
  3. Pb Session : entity class not found
    Par fagma dans le forum Hibernate
    Réponses: 4
    Dernier message: 03/05/2011, 10h05
  4. Réponses: 4
    Dernier message: 11/06/2010, 13h29
  5. Mapping Exception : component class not found
    Par lion13 dans le forum Hibernate
    Réponses: 2
    Dernier message: 06/05/2008, 14h30

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