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

Java EE Discussion :

Tutoriel de Serge Tahe Java EE5 : des soucis avec la couche metier


Sujet :

Java EE

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Architecte de système d'information
    Inscrit en
    Juin 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Guinée

    Informations professionnelles :
    Activité : Architecte de système d'information
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2012
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Tutoriel de Serge Tahe Java EE5 : des soucis avec la couche metier
    Bonjour à tous
    Je suis le tutoriel de Serge Tahé:Introduction à Java EE 5 a l'adresse suivante http://tahe.developpez.com/java/javaee/ mais des j'ai des soucis a l’implémentation de la couche métier. J'ai déjà teste la couche Dao, elle s’exécute bien.

    L'interface de la classe métier et sont implémentation 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
     
    package metier;
     
    import entites.Employes;
    import java.util.List;
     
    /**
     *
     * @author Baba
     */
    public interface IMetier {
        //obtenir la feuille de salaire
        public FeuilleSalaire CalculerFeuilleSalaire(String SS, double nbHeureTrav, int nbJoursTrav);
        //Liste des employes
        public List<Employes> findAllEmployes();
     
    }

    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
     
    package metier;
     
    import dao.ICotisationsDao;
    import dao.IEmployesDao;
    import dao.IIndemnitesDao;
    import entites.Cotisations;
    import entites.Employes;
    import entites.Indemnites;
    import exception.PamException;
    import java.util.List;
    import org.springframework.transaction.annotation.Transactional;
     
    /**
     *
     * @author Baba
     */
    @Transactional
    public class Metier implements IMetier {
        // reference sur la couche Dao
        private ICotisationsDao cotisationDao = null;
        private IEmployesDao employeDao = null;    
        private IIndemnitesDao indemniteDao = null;
        //private ElementsSalaire elementsSalaire ;
         // getters and setters
     
        public ICotisationsDao getCotisationDao() {
            return cotisationDao;
        }
     
        public void setCotisationDao(ICotisationsDao cotisationDao) {
            this.cotisationDao = cotisationDao;
        }
     
        public IEmployesDao getEmployeDao() {
            return employeDao;
        }
     
        public void setEmployeDao(IEmployesDao employeDao) {
            this.employeDao = employeDao;
        }
     
        public IIndemnitesDao getIndemniteDao() {
            return indemniteDao;
        }
     
        public void setIndemniteDao(IIndemnitesDao indemniteDao) {
            this.indemniteDao = indemniteDao;
        }
     
        @Override
        public FeuilleSalaire CalculerFeuilleSalaire(String SS, double nbHeureTrav, int nbJoursTrav) {
            Employes employes = employeDao.find(SS);
            // on rend une exception si l'employe n'existe pas
     
            if(employes == null) {
                throw new PamException(String.format("L'Employe de n SS n'existe pas", SS),1);
            }
           Cotisations cotisations = (Cotisations) cotisationDao.findAll();
           Indemnites indemnites = (Indemnites) indemniteDao.findAll();
     
           ElementsSalaire  elementsSalaire   = new ElementsSalaire();
           elementsSalaire.getSalaireBase();
           elementsSalaire.getCotisationsSociales();
           elementsSalaire.getIndemnitesEntretiens();
           elementsSalaire.getIndemnitesRepas();
           elementsSalaire.getSalaireNet();
     
           return new FeuilleSalaire(employes, cotisations, elementsSalaire);
     
        }
     
        @Override
        public List<Employes> findAllEmployes() {
            try {
                return employeDao.findAll();
            }catch(Throwable th) {
            throw new PamException(th, 1);
            }
        }  
    }
    Les deux classes complémentaires dans la couche métier pour le calcul du salaire 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
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
     
    package metier;
     
    import entites.Cotisations;
    import entites.Employes;
    import entites.Indemnites;
    import java.io.Serializable;
     
    /**
     *
     * @author Baba
     */
    public class FeuilleSalaire implements Serializable {
        //champs prives
        private Employes employes;
        private Cotisations cotisations;
        private Indemnites indemnites;
        private ElementsSalaire elementsSalaire;
     
        public FeuilleSalaire(){
     
        }
     
        public FeuilleSalaire(Employes employes, Cotisations cotisations, ElementsSalaire elementsSalaire) {
            this.employes = employes;
            this.cotisations = cotisations;
            this.elementsSalaire = elementsSalaire;
        }
     
        public Employes getEmployes() {
            return employes;
        }
     
        public void setEmployes(Employes employes) {
            this.employes = employes;
        }
     
        public Cotisations getCotisations() {
            return cotisations;
        }
     
        public void setCotisations(Cotisations cotisations) {
            this.cotisations = cotisations;
        }
     
        public ElementsSalaire getElemntsSalaire() {
            return elementsSalaire;
        }
     
        public void setElemntsSalaire(ElementsSalaire elemntsSalaire) {
            this.elementsSalaire = elemntsSalaire;
        }
     
        public Indemnites getIndemnites() {
            return indemnites;
        }
     
        public void setIndemnites(Indemnites indemnites) {
            this.indemnites = indemnites;
        }
     
        public ElementsSalaire getElementsSalaire() {
            return elementsSalaire;
        }
     
        public void setElementsSalaire(ElementsSalaire elementsSalaire) {
            this.elementsSalaire = elementsSalaire;
        }
     
     
        //toString
        @Override
        public String toString() {
            return "[" + employes + "," + cotisations + "," + elementsSalaire + "]";
     
        }
     
    }
    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
     
    package metier;
     
    import java.io.Serializable;
     
    /**
     *
     * @author Baba
     */
    public class ElementsSalaire implements Serializable {
        //champs prives
        private double salaireBase;
        private double cotisationsSociales;
        private double indemnitesEntretiens;
        private double indemnitesRepas;
        private double salaireNet;
     
        public ElementsSalaire() {
        }
     
        public ElementsSalaire(double salaireBase, double cotisationsSociales, double indemnitesEntretiens, double indemnitesRepas, double salaireNet) {
            this.salaireBase = salaireBase;
            this.cotisationsSociales = cotisationsSociales;
            this.indemnitesEntretiens = indemnitesEntretiens;
            this.indemnitesRepas = indemnitesRepas;
            this.salaireNet = salaireNet;
        }
     
        public double getSalaireBase() {
            return salaireBase;
        }
     
        public void setSalaireBase(double salaireBase) {
            this.salaireBase = salaireBase;
        }
     
        public double getCotisationsSociales() {
            return cotisationsSociales;
        }
     
        public void setCotisationsSociales(double cotisationsSociales) {
            this.cotisationsSociales = cotisationsSociales;
        }
     
        public double getIndemnitesEntretiens() {
            return indemnitesEntretiens;
        }
     
        public void setIndemnitesEntretiens(double indemnitesEntretiens) {
            this.indemnitesEntretiens = indemnitesEntretiens;
        }
     
        public double getIndemnitesRepas() {
            return indemnitesRepas;
        }
     
        public void setIndemnitesRepas(double indemnitesRepas) {
            this.indemnitesRepas = indemnitesRepas;
        }
     
        public double getSalaireNet() {
            return salaireNet;
        }
     
        public void setSalaireNet(double salaireNet) {
            this.salaireNet = salaireNet;
        }
     
        @Override
        public String toString(){
            return "[Salaire de base = " + salaireBase + ",Cotisations sociales = " + cotisationsSociales +
                    ",Indemnites d'entretien = " + indemnitesEntretiens + ", Indemnites de repas = " +indemnitesRepas+
                    ", Salaire net = " + salaireNet + "]";
        }
     
    }
    Ma classe de test 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
    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
     
    package metier;
     
    import dao.ICotisationsDao;
    import dao.IEmployesDao;
    import dao.IIndemnitesDao;
    import entites.Cotisations;
    import entites.Employes;
    import entites.Indemnites;
    import org.junit.BeforeClass;
    import org.junit.Test;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
     
    /**
     *
     * @author Baba
     */
    public class JUnitMetier {
     
            // couche métier
            private static IMetier metier;
     
        @BeforeClass
        public static void init() {
            //log("init");
            ApplicationContext ctx =  new ClassPathXmlApplicationContext("spring-metier-dao.xml");
             metier = (IMetier) ctx.getBean("metier");
            //couches Dao 
             IEmployesDao employeDao = (IEmployesDao) ctx.getBean("employeDao");
             IIndemnitesDao indemniteDao = (IIndemnitesDao) ctx.getBean("indemniteDao");
             ICotisationsDao cotisationDao = (ICotisationsDao) ctx.getBean("cotisationDao");
            //clean();
            //fill();
            System.out.println("Salut");
     
            // on vide la base
            for(Employes employe : employeDao.findAll()) {
                employeDao.destroy(employe);
            }
            for(Cotisations cotisation : cotisationDao.findAll()) {
                cotisationDao.destroy(cotisation);
            }
            for(Indemnites indemnite : indemniteDao.findAll()) {
                indemniteDao.destroy(indemnite);
            }
     
            // on remplit la base
            Indemnites indemnite1 = new Indemnites(1,1.93,2,2,12);
            Indemnites indemnite2 = new Indemnites(2,2.1,3,3,15);
            indemnite1 = indemniteDao.create(indemnite1);
            indemnite2 = indemniteDao.create(indemnite2);
            employeDao.create(new Employes("Baba", "Camara", "254104940426058","5 rue Matam","Matam","Conakry",indemnite2));
            employeDao.create(new Employes("Aissata", "Camara", "254104940426060","5 rue Matam","Matam","Conakry",indemnite1));
     
            cotisationDao.create(new Cotisations(3.49,6.15,9.39,7.88));
     
     
        }
     
        public static void log(String message) {
        System.out.println("----------- " + message);
        }
     
     
       // test
        @Test
        public void test01(){
     
        // calcul de feuilles de salaire
            System.out.println(metier.CalculerFeuilleSalaire("254104940426060", 30, 5));
            System.out.println(metier.CalculerFeuilleSalaire("254104940426058", 150, 20));
        } 
    }
    A l’exécution j'obtiens le message 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
    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
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
     
    Tests run: 0, Failures: 0, Errors: 1, Time elapsed: 10,218 sec
     
    ------------- Standard Output ---------------
    Salut
    ------------- ---------------- ---------------
    ------------- Standard Error -----------------
    juil. 04, 2014 11:55:56 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    Infos: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@277e07ae: display name [org.springframework.context.support.ClassPathXmlApplicationContext@277e07ae]; startup date [Fri Jul 04 11:55:56 UTC 2014]; root of context hierarchy
    juil. 04, 2014 11:55:56 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    Infos: Loading XML bean definitions from class path resource [spring-metier-dao.xml]
    juil. 04, 2014 11:55:57 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
    Infos: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@277e07ae]: org.springframework.beans.factory.support.DefaultListableBeanFactory@44f5df97
    juil. 04, 2014 11:55:57 AM org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
    Infos: Bean 'dataSource' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    juil. 04, 2014 11:55:57 AM org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
    Infos: Bean 'org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter#41518a15' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    juil. 04, 2014 11:55:57 AM org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
    Infos: Bean 'org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver#50408a33' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    juil. 04, 2014 11:55:57 AM org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean createNativeEntityManagerFactory
    Infos: Building JPA container EntityManagerFactory for persistence unit 'PamSpringPU'
    juil. 04, 2014 11:55:57 AM org.hibernate.cfg.annotations.Version <clinit>
    Infos: Hibernate Annotations 3.3.1.GA
    juil. 04, 2014 11:55:57 AM org.hibernate.cfg.Environment <clinit>
    Infos: Hibernate 3.2.5
    juil. 04, 2014 11:55:57 AM org.hibernate.cfg.Environment <clinit>
    Infos: hibernate.properties not found
    juil. 04, 2014 11:55:58 AM org.hibernate.cfg.Environment buildBytecodeProvider
    Infos: Bytecode provider name : cglib
    juil. 04, 2014 11:55:58 AM org.hibernate.cfg.Environment <clinit>
    Infos: using JDK 1.4 java.sql.Timestamp handling
    juil. 04, 2014 11:55:58 AM org.hibernate.ejb.Version <clinit>
    Infos: Hibernate EntityManager 3.3.2.GA
    juil. 04, 2014 11:55:58 AM org.hibernate.ejb.Ejb3Configuration configure
    Infos: Processing PersistenceUnitInfo [
    	name: PamSpringPU
    	...]
    juil. 04, 2014 11:55:58 AM org.hibernate.cfg.AnnotationBinder bindClass
    Infos: Binding entity from annotated class: entites.Cotisations
    juil. 04, 2014 11:55:58 AM org.hibernate.cfg.annotations.QueryBinder bindQuery
    Infos: Binding Named query: Cotisations.findAll => SELECT r FROM Cotisations r
    juil. 04, 2014 11:55:58 AM org.hibernate.cfg.annotations.EntityBinder bindTable
    Infos: Bind entity entites.Cotisations on table cotisations
    juil. 04, 2014 11:55:58 AM org.hibernate.cfg.AnnotationBinder bindClass
    Infos: Binding entity from annotated class: entites.Employes
    juil. 04, 2014 11:55:58 AM org.hibernate.cfg.annotations.EntityBinder bindTable
    Infos: Bind entity entites.Employes on table employes
    juil. 04, 2014 11:55:59 AM org.hibernate.cfg.AnnotationBinder bindClass
    Infos: Binding entity from annotated class: entites.Indemnites
    juil. 04, 2014 11:55:59 AM org.hibernate.cfg.annotations.EntityBinder bindTable
    Infos: Bind entity entites.Indemnites on table indemnites
    juil. 04, 2014 11:55:59 AM org.hibernate.cfg.annotations.CollectionBinder bindOneToManySecondPass
    Infos: Mapping collection: entites.Indemnites.employes -> employes
    juil. 04, 2014 11:55:59 AM org.hibernate.cfg.AnnotationConfiguration secondPassCompile
    Infos: Hibernate Validator not found: ignoring
    juil. 04, 2014 11:55:59 AM org.hibernate.connection.ConnectionProviderFactory newConnectionProvider
    Infos: Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
    juil. 04, 2014 11:55:59 AM org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider configure
    Infos: Using provided datasource
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: RDBMS: MySQL, version: 5.5.20-log
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.18 ( Revision: tonci.grgin@oracle.com-20110930151701-jfj14ddfq48ifkfq )
    juil. 04, 2014 11:56:02 AM org.hibernate.dialect.Dialect <init>
    Infos: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    juil. 04, 2014 11:56:02 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
    Infos: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
    juil. 04, 2014 11:56:02 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
    Infos: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Automatic flush during beforeCompletion(): disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Automatic session close at end of transaction: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: JDBC batch size: 15
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: JDBC batch updates for versioned data: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Scrollable result sets: enabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: JDBC3 getGeneratedKeys(): enabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Connection release mode: auto
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Maximum outer join fetch depth: 2
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Default batch fetch size: 1
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Generate SQL with comments: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Order SQL updates by primary key: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Order SQL inserts for batching: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
    Infos: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
    juil. 04, 2014 11:56:02 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
    Infos: Using ASTQueryTranslatorFactory
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Query language substitutions: {}
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: JPA-QL strict compliance: enabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Second-level cache: enabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Query cache: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory createCacheProvider
    Infos: Cache provider: org.hibernate.cache.NoCacheProvider
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Optimize cache for minimal puts: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Structured second-level cache entries: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Statistics: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Deleted entity synthetic identifier rollback: disabled
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Default entity-mode: pojo
    juil. 04, 2014 11:56:02 AM org.hibernate.cfg.SettingsFactory buildSettings
    Infos: Named query checking : enabled
    juil. 04, 2014 11:56:02 AM org.hibernate.impl.SessionFactoryImpl <init>
    Infos: building session factory
    juil. 04, 2014 11:56:03 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
    Infos: Not binding factory to JNDI, no JNDI name configured
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    Infos: Running hbm2ddl schema update
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    Infos: fetching database metadata
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    Infos: updating schema
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: table found: dbPam.cotisations
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: columns: [secu, id, csgd, retraite, csgrds, version]
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: foreign keys: []
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: indexes: [primary]
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: table found: dbPam.employes
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: columns: [prenom, id, cp, adresse, ville, ss, indemnite_id, nom, version]
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: foreign keys: [fk4722e6bc3e7ac411, fk_employes_indemnite_id, fk4722e6bc398c5d0]
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: indexes: [fk4722e6bc3e7ac411, fk_employes_indemnite_id, primary, ss, fk4722e6bc398c5d0]
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: table found: dbPam.indemnites
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: columns: [id, indice, repas_jour, base_heure, indemnites_cp, entretien_jour, version]
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: foreign keys: []
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
    Infos: indexes: [indice, primary]
    juil. 04, 2014 11:56:03 AM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
    Infos: schema update complete
    juil. 04, 2014 11:56:04 AM org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
    Infos: Bean 'entityManagerFactory' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    juil. 04, 2014 11:56:04 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    Infos: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@44f5df97: defining beans [employeDao,indemniteDao,cotisationDao,metier,entityManagerFactory,dataSource,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,txManager,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0]; root of factory hierarchy
    ------------- ---------------- ---------------
    Testcase: metier.JUnitMetier:	Caused an ERROR
    javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: entites.Employes.indemnites
    exception.PamException: javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: entites.Employes.indemnites
    	at dao.EmployeDao.create(EmployeDao.java:23)
    	at metier.JUnitMetier.init(JUnitMetier.java:63)
    Caused by: javax.persistence.PersistenceException: org.hibernate.PropertyValueException: not-null property references a null or transient value: entites.Employes.indemnites
    	at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:637)
    	at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
    	at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:358)
    	at com.sun.proxy.$Proxy22.persist(Unknown Source)
    	at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:198)
    	at com.sun.proxy.$Proxy22.persist(Unknown Source)
    	at dao.EmployeDao.create(EmployeDao.java:20)
    Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: entites.Employes.indemnites
    	at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
    	at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:290)
    	at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
    	at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
    	at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
    at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:131)
    	at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:87)
    	at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
    	at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
    	at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
    	at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:596)
    	at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220)
     
     
    Test metier.JUnitMetier FAILED
    test:
    Deleting: C:\Users\Baba\AppData\Local\Temp\TEST-metier.JUnitMetier.xml
    BUILD SUCCESSFUL (total time: 18 seconds)

  2. #2
    Membre chevronné Avatar de jeffray03
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2008
    Messages
    1 501
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Allemagne

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 501
    Points : 2 120
    Points
    2 120
    Par défaut
    salut,
    le message te dit qu´il ya une propriéte non null qui referencie sur un Propriéte null ou Transient.
    peux-tu nous donner le contenu de EmployeDao et Employe?

    Eric

  3. #3
    Nouveau Candidat au Club
    Homme Profil pro
    Architecte de système d'information
    Inscrit en
    Juin 2012
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Guinée

    Informations professionnelles :
    Activité : Architecte de système d'information
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2012
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    Salut

    Voici la classe EmployeDao
    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
     
    package dao;
     
    import entites.Employes;
    import exception.PamException;
    import java.util.List;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
     
    /**
     *
     * @author Baba
     */
    public class EmployeDao implements IEmployesDao {
                    @PersistenceContext
                    private EntityManager em;
     
        @Override
        public Employes create(Employes employes) {
            try{
                em.persist(employes);
     
            }catch(Throwable th){
            throw new PamException(th, 1);
            }
               return employes;
        }
     
        @Override
        public Employes edit(Employes employes) {
            try{
                return em.merge(employes);
            }catch(Throwable th) {
            throw new PamException(th, 2);
            }
        }
     
        @Override
        public void destroy(Employes employes) {
            try{
                //em.persist(employes);
                em.remove(em.merge(employes));
            }catch(Throwable th){
            throw new PamException(th, 3);
            }
        }
     
        @Override
        public Employes find(Long id) {
            try{
                return (Employes) em.find(Employes.class, id);
            }catch(Throwable th) {
            throw new PamException(th, 4);
            }
        }
     
        @Override
        public List<Employes> findAll() {
            try{
                return em.createQuery("select e from Employes e").getResultList();
            }catch(Throwable th){
            throw new PamException(th, 5);
            }
        }
     
        @Override
        public Employes find(String ss) {
            try {
                return (Employes)em.find(Employes.class, ss);
            }catch(Throwable th) {
            throw new PamException(th, 6);
            }
        }    
     
    }
    Et la classe Employe

    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
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
     
    package entites;
     
    import java.io.Serializable;
    import javax.persistence.Basic;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.JoinColumn;
    import javax.persistence.ManyToOne;
    import javax.persistence.Table;
    import javax.validation.constraints.NotNull;
    import javax.validation.constraints.Size;
     
    /**
     *
     * @author Baba
     */
    @Entity
    @Table(name = "employes")
    public class Employes implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)
        @Basic(optional = false)
        @Column(name = "ID")
        private Long id;
        @Basic(optional = false)
        @NotNull
        @Size(min = 1, max = 20)
        @Column(name = "PRENOM")
        private String prenom;
        @Basic(optional = false)
        @NotNull
        @Size(min = 1, max = 15)
        @Column(name = "SS")
        private String ss;
        @Basic(optional = false)
        @NotNull
        @Size(min = 1, max = 50)
        @Column(name = "ADRESSE")
        private String adresse;
        @Basic(optional = false)
        @NotNull
        @Size(min = 1, max = 5)
        @Column(name = "CP")
        private String cp;
        @Basic(optional = false)
        @NotNull
        @Size(min = 1, max = 30)
        @Column(name = "VILLE")
        private String ville;
        @Basic(optional = false)
        @NotNull
        @Size(min = 1, max = 30)
        @Column(name = "NOM")
        private String nom;
        @Basic(optional = false)
        @NotNull
        @Column(name = "VERSION")
        private int version;
        @JoinColumn(name = "INDEMNITE_ID", referencedColumnName = "ID")
        @ManyToOne(optional = false)
        private Indemnites indemnites;
     
        public Employes() {
        }
     
       public Employes(Long id) {
            this.id = id;
        }
     
        public Employes(String prenom, String nom, String ss, String adresse, String cp, String ville, Indemnites indemnites) {
            this.prenom = prenom;
            this.ss = ss;
            this.adresse = adresse;
            this.cp = cp;
            this.ville = ville;
            this.nom = nom;
            this.indemnites = indemnites;
        }
     
        public Long getId() {
            return id;
        }
     
        public void setId(Long id) {
            this.id = id;
        }
     
        public String getPrenom() {
            return prenom;
        }
     
        public void setPrenom(String prenom) {
            this.prenom = prenom;
        }
     
        public String getSs() {
            return ss;
        }
     
        public void setSs(String ss) {
            this.ss = ss;
        }
     
        public String getAdresse() {
            return adresse;
        }
     
        public void setAdresse(String adresse) {
            this.adresse = adresse;
        }
     
        public String getCp() {
            return cp;
        }
     
        public void setCp(String cp) {
            this.cp = cp;
        }
     
        public String getVille() {
            return ville;
        }
     
        public void setVille(String ville) {
            this.ville = ville;
        }
     
        public String getNom() {
            return nom;
        }
     
        public void setNom(String nom) {
            this.nom = nom;
        }
     
        public int getVersion() {
            return version;
        }
     
        public void setVersion(int version) {
            this.version = version;
        }
     
        public Indemnites getIndemnites() {
            return indemnites;
        }
     
        public void setIndemnites(Indemnites indemnites) {
            this.indemnites = indemnites;
        }
     
        @Override
        public int hashCode() {
            int hash = 0;
            hash += (id != null ? id.hashCode() : 0);
            return hash;
        }
     
        @Override
        public boolean equals(Object object) {
            // TODO: Warning - this method won't work in the case the id fields are not set
            if (!(object instanceof Employes)) {
                return false;
            }
            Employes other = (Employes) object;
            if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
                return false;
            }
            return true;
        }
     
        @Override
        public String toString(){
        return "entites.Employes[id="  + getId()
        + ",version="+getVersion()
        +",SS="+getSs()
        + ",nom="+getNom()
        + ",prenom="+getPrenom()
        + ",adresse="+getAdresse()
        +",ville="+getVille()
        +",code postal="+getCp()
        +",indice="+getIndemnites().getIndice()
        +"]";
     
        }  
    }

  4. #4
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Bonjour,
    L'erreur est une violation de cette contrainte :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    @ManyToOne(optional = false)
        private Indemnites indemnites;
    . Tu essaies de créer un Employe avec une indeminité nulle, alors que l’indemnité en question ne doit pas être optionnelle.
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

Discussions similaires

  1. Réponses: 7
    Dernier message: 19/11/2011, 14h05
  2. [CognosScript] Encore des soucis avec une connexion ODBC
    Par ben_harper dans le forum Cognos
    Réponses: 1
    Dernier message: 23/06/2009, 19h08
  3. Des soucis avec mon application Excel sur les contacts
    Par diddle dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 27/11/2007, 19h50
  4. J'ai des soucis avec Delphi8 ShellExecute...
    Par manu00 dans le forum Delphi .NET
    Réponses: 6
    Dernier message: 25/07/2004, 08h38

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