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 :

Un flush supprime l'instance de l'entité ?


Sujet :

Hibernate Java

  1. #1
    Modérateur

    Avatar de CinePhil
    Homme Profil pro
    Ingénieur d'études en informatique
    Inscrit en
    Août 2006
    Messages
    16 799
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur d'études en informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2006
    Messages : 16 799
    Points : 34 031
    Points
    34 031
    Billets dans le blog
    14
    Par défaut Un flush supprime l'instance de l'entité ?
    Décidément, je vais devenir dingue avec Hibernate !

    Encore une fois, je précise que je découvre un nouveau monde avec Seam et tout ce qui tourne avec.

    En attendant d'autres informations pour résoudre ce problème, je passe à autre chose...

    Dans Identifier.java, j'ai, entre autres, ceci :
    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
        @Out(value="Nom", required=false, scope = ScopeType.SESSION)
        private String nom;
     
        @Out(value="Prenom", required=false, scope = ScopeType.SESSION)
        private String prenom;
     
        @Out(value="MotPasse", required=false, scope = ScopeType.CONVERSATION)
        private String motPasse;
     
        public boolean identifier() 
        {
            try
            {
                log.info("identification.identifier() "
                        + "Tentative d'identification avec les paramètres suivants : "
                        + "#{identification.nom}, #{identification.prenom}, #{identification.dateNaissance}");
     
                // Recherche de l'étudiant
                Query query = entityManager.createQuery(
                        "from ThEtudiantEtu e " +
                        "where e.prsNom = :nom " +
                            "and e.prsPrenom = :prenom " +
                            "and e.etuDateNaissance = :dateNaissance ");
                query.setParameter("nom", this.getNom());
                query.setParameter("prenom", this.getPrenom());
                query.setParameter("dateNaissance", this.getDateNaissance());
     
                ThEtudiantEtu etudiant = (ThEtudiantEtu) query.getSingleResult();
     
                // Génération de son mot de passe
                log.info("identification.identifier() : affectation du mot de passe");
                this.setMotPasse(etudiant.generatePassword(this.getPrenom(), this.getNom()));
                setAdmis(true);
     
                setPageSuivante("/login.xhtml");
                return true;
            }
    Jusque là, ça fonctionne. La redirection se fait bien, les propriétés en @Out sont bien exportées et je peux les afficher sur la page de login.

    Mais c'est bien beau de générer un mot de passe, encore faut-il l'injecter dans la BDD ! Alors j'ai modifié la génération du mot de passe de cette façon :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
                // Génération de son mot de passe
                log.info("identification.identifier() : affectation du mot de passe");
                this.setMotPasse(etudiant.generatePassword(this.getPrenom(), this.getNom()));
                log.info("identification.identifier() : enregistrement du mot de passe #{identification.motPasse}");
                etudiant.setUtiMotPasse(this.getMotPasse());
                entityManager.flush();
                log.info("identification.identifier() : mot de passe enregistré");
    Miracle ! Ça fonctionne du premier coup ! Le mot de passe s'enregistre bien dans la table pour l'utilisateur qui vient de s'authentifier.
    Mais la redirection vers la page de login plante, apparemment parce qu'il ne trouve plus le user !
    15:23:22,228 INFO [Identification] identification.identifier() : affectation du mot de passe
    15:23:22,228 INFO [Identification] identification.identifier() : enregistrement du mot de passe T091210T
    Hibernate:
    update
    stamas.th_utilisateur_uti
    set
    uti_id_type_utilisateur=?,
    uti_login=?,
    uti_mot_passe=?
    where
    uti_id_personne=?
    15:23:22,248 INFO [Identification] identification.identifier() : mot de passe enregistré
    15:23:22,249 DEBUG [Component] trying to inject with hierarchical context search: entityManager
    15:23:22,249 DEBUG [Component] trying to inject with hierarchical context search: statusMessages
    15:23:22,249 DEBUG [Component] trying to inject with hierarchical context search: identity
    15:23:22,250 DEBUG [Component] trying to inject with hierarchical context search: credentials
    15:23:22,259 DEBUG [Component] trying to inject with hierarchical context search: facesMessages
    15:23:22,261 DEBUG [Component] trying to inject with hierarchical context search: entityManager
    15:23:22,261 DEBUG [Component] trying to inject with hierarchical context search: statusMessages
    15:23:22,262 DEBUG [Component] trying to inject with hierarchical context search: identity
    15:23:22,262 DEBUG [Component] trying to inject with hierarchical context search: credentials
    15:23:22,273 DEBUG [Component] trying to inject with hierarchical context search: facesMessages
    15:23:22,279 DEBUG [Navigator] redirecting to: /login.xhtml
    15:23:22,280 DEBUG [FacesManager] redirecting to: /stamas/login.seam?cid=3
    15:23:22,280 DEBUG [SeamPhaseListener] committing transaction after phase: INVOKE_APPLICATION 5
    15:23:22,280 DEBUG [EntityTransaction] committing JPA resource-local transaction
    15:23:22,282 DEBUG [Manager] Storing conversation state: 3
    15:23:22,282 DEBUG [FacesLifecycle] After render response, destroying contexts
    15:23:22,282 DEBUG [Contexts] destroying business process context
    15:23:22,282 DEBUG [Contexts] flushing server-side conversation context
    15:23:22,283 DEBUG [Contexts] flushing session context
    15:23:22,283 DEBUG [Contexts] destroying event context
    15:23:22,283 DEBUG [Contexts] destroying: com.sun.faces.util.RequestStateManager
    15:23:22,283 DEBUG [Contexts] destroying: org.jboss.seam.core.manager
    15:23:22,283 DEBUG [Contexts] destroying: org.jboss.seam.faces.validation
    15:23:22,283 DEBUG [Contexts] destroying: org.jboss.seam.transaction.synchronizations
    15:23:22,283 DEBUG [Contexts] destroying: org.jboss.seam.web.requestContextPath
    15:23:22,283 DEBUG [Contexts] destroying: com.exade.vcp.Filter.ResponseWrapper
    15:23:22,283 DEBUG [Contexts] destroying: org.jboss.seam.core.conversationPropagation
    15:23:22,284 DEBUG [Contexts] destroying: org.jboss.seam.faces.dateConverter
    15:23:22,284 DEBUG [Contexts] destroying: com.exade.vcp.Filter.done
    15:23:22,284 DEBUG [Contexts] destroying: identification
    15:23:22,284 DEBUG [Contexts] destroying: org.jboss.seam.transaction.transaction
    15:23:22,284 DEBUG [Contexts] destroying: org.jboss.seam.web.servletContexts
    15:23:22,284 DEBUG [Contexts] destroying: org.jboss.seam.core.events
    15:23:22,284 DEBUG [Contexts] destroying: org.jboss.seam.web.requestServletPath
    15:23:22,284 DEBUG [Contexts] destroying: ajaxContext
    15:23:22,284 DEBUG [FacesLifecycle] <<< End JSF request for /stamas/identification.seam
    15:23:22,297 DEBUG [FacesLifecycle] >>> Begin JSF request for /stamas/login.seam
    15:23:22,298 DEBUG [Manager] Restoring conversation with id: 3
    15:23:22,298 DEBUG [SeamPhaseListener] beginning transaction prior to phase: RENDER_RESPONSE 6
    15:23:22,299 DEBUG [EntityTransaction] beginning JPA resource-local transaction
    15:23:22,345 DEBUG [Component] trying to inject with hierarchical context search: identity
    15:23:22,346 DEBUG [Component] trying to inject with hierarchical context search: credentials
    15:23:22,346 DEBUG [Component] trying to inject with hierarchical context search: entityManager
    15:23:22,346 DEBUG [EntityTransaction] registering synchronization: ManagedPersistenceContext(java:/entityManager)
    15:23:22,347 DEBUG [Component] trying to inject from specified context: MotPasse, scope: EVENT
    15:23:22,402 DEBUG [Component] trying to inject with hierarchical context search: identity
    15:23:22,402 DEBUG [Component] trying to inject with hierarchical context search: credentials
    15:23:22,403 DEBUG [Component] trying to inject with hierarchical context search: entityManager
    15:23:22,403 DEBUG [Component] trying to inject from specified context: MotPasse, scope: EVENT
    15:23:22,410 DEBUG [Component] trying to inject with hierarchical context search: identity
    15:23:22,410 DEBUG [Component] trying to inject with hierarchical context search: credentials
    15:23:22,411 DEBUG [Component] trying to inject with hierarchical context search: entityManager
    15:23:22,411 DEBUG [Component] trying to inject from specified context: MotPasse, scope: EVENT
    15:23:22,411 DEBUG [SeamPhaseListener] committing transaction after phase: RENDER_RESPONSE 6
    15:23:22,411 DEBUG [EntityTransaction] committing JPA resource-local transaction
    15:23:22,412 DEBUG [Manager] Discarding conversation state: 3
    15:23:22,412 DEBUG [FacesLifecycle] After render response, destroying contexts
    15:23:22,412 DEBUG [Contexts] destroying business process context
    15:23:22,412 DEBUG [Contexts] destroying conversation context
    15:23:22,412 DEBUG [Contexts] destroying: org.jboss.seam.persistence.persistenceContexts
    15:23:22,413 DEBUG [Contexts] destroying: org.jboss.seam.core.conversation
    15:23:22,413 DEBUG [Contexts] destroying: MotPasse
    15:23:22,413 DEBUG [Contexts] destroying: org.jboss.seam.international.statusMessages
    15:23:22,413 DEBUG [Contexts] destroying: entityManager
    15:23:22,413 DEBUG [ManagedPersistenceContext] destroying seam managed persistence context for persistence unit: java:/entityManager
    15:23:22,413 DEBUG [Contexts] flushing server-side conversation context
    15:23:22,413 DEBUG [Contexts] flushing session context
    15:23:22,414 DEBUG [Contexts] destroying event context
    15:23:22,414 DEBUG [Contexts] destroying: com.sun.faces.util.RequestStateManager
    15:23:22,414 DEBUG [Contexts] destroying: org.jboss.seam.core.manager
    15:23:22,414 DEBUG [Contexts] destroying: facelets.ContentType
    15:23:22,414 DEBUG [Contexts] destroying: org.jboss.seam.transaction.synchronizations
    15:23:22,414 DEBUG [Contexts] destroying: org.jboss.seam.web.requestContextPath
    15:23:22,414 DEBUG [Contexts] destroying: com.exade.vcp.Filter.ResponseWrapper
    15:23:22,414 DEBUG [Contexts] destroying: org.jboss.seam.core.conversationPropagation
    15:23:22,414 DEBUG [Contexts] destroying: facelets.Encoding
    15:23:22,414 DEBUG [Contexts] destroying: authenticator
    15:23:22,414 DEBUG [Contexts] destroying: com.exade.vcp.Filter.done
    15:23:22,414 DEBUG [Contexts] destroying: org.jboss.seam.transaction.transaction
    15:23:22,415 DEBUG [Contexts] destroying: org.jboss.seam.web.servletContexts
    15:23:22,415 DEBUG [Contexts] destroying: org.jboss.seam.core.events
    15:23:22,415 DEBUG [Contexts] destroying: org.jboss.seam.web.requestServletPath
    15:23:22,415 DEBUG [Contexts] destroying: ajaxContext
    15:23:22,415 DEBUG [FacesLifecycle] <<< End JSF request for /stamas/login.seam
    15:23:22,415 DEBUG [ExceptionFilter] handling uncaught exception
    javax.servlet.ServletException: @Out attribute requires non-null value: authenticator.user
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
    ...
    Caused by: org.jboss.seam.RequiredException: @Out attribute requires non-null value: authenticator.user
    at org.jboss.seam.Component.outjectAttribute(Component.java:1764)
    ...
    15:23:22,416 DEBUG [ExceptionFilter] exception root cause
    org.jboss.seam.RequiredException: @Out attribute requires non-null value: authenticator.user
    at org.jboss.seam.Component.outjectAttribute(Component.java:1764)
    Quelqu'un peut m'expliquer ce qui se passe ?
    Philippe Leménager. Ingénieur d'étude à l'École Nationale Supérieure de Formation de l'Enseignement Agricole. Autoentrepreneur.
    Mon ancien blog sur la conception des BDD, le langage SQL, le PHP... et mon nouveau blog sur les mêmes sujets.
    « Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
    À la maison comme au bureau, j'utilise la suite Linux Mageïa !

  2. #2
    Modérateur

    Avatar de CinePhil
    Homme Profil pro
    Ingénieur d'études en informatique
    Inscrit en
    Août 2006
    Messages
    16 799
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur d'études en informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2006
    Messages : 16 799
    Points : 34 031
    Points
    34 031
    Billets dans le blog
    14
    Par défaut
    Je viens d'essayer avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    entityManager.merge(etudiant);
    Même punition !
    Philippe Leménager. Ingénieur d'étude à l'École Nationale Supérieure de Formation de l'Enseignement Agricole. Autoentrepreneur.
    Mon ancien blog sur la conception des BDD, le langage SQL, le PHP... et mon nouveau blog sur les mêmes sujets.
    « Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
    À la maison comme au bureau, j'utilise la suite Linux Mageïa !

  3. #3
    Modérateur

    Avatar de CinePhil
    Homme Profil pro
    Ingénieur d'études en informatique
    Inscrit en
    Août 2006
    Messages
    16 799
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur d'études en informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2006
    Messages : 16 799
    Points : 34 031
    Points
    34 031
    Billets dans le blog
    14
    Par défaut
    J'y suis arrivé en détachant la méthode generateMD5 utilisée par generatePassword de l'entité ThUtilisateurUti. Elle me posait aussi des problème dans Authenticator.java.

    EDIT : J'ai parlé trop vite !

    Nouveau problème sur le même sujet dans une autre discussion.
    Philippe Leménager. Ingénieur d'étude à l'École Nationale Supérieure de Formation de l'Enseignement Agricole. Autoentrepreneur.
    Mon ancien blog sur la conception des BDD, le langage SQL, le PHP... et mon nouveau blog sur les mêmes sujets.
    « Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
    À la maison comme au bureau, j'utilise la suite Linux Mageïa !

  4. #4
    Modérateur

    Avatar de CinePhil
    Homme Profil pro
    Ingénieur d'études en informatique
    Inscrit en
    Août 2006
    Messages
    16 799
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur d'études en informatique
    Secteur : Enseignement

    Informations forums :
    Inscription : Août 2006
    Messages : 16 799
    Points : 34 031
    Points
    34 031
    Billets dans le blog
    14
    Par défaut
    Bon, problème résolu grâce à tchize dans l'autre discussion.
    Philippe Leménager. Ingénieur d'étude à l'École Nationale Supérieure de Formation de l'Enseignement Agricole. Autoentrepreneur.
    Mon ancien blog sur la conception des BDD, le langage SQL, le PHP... et mon nouveau blog sur les mêmes sujets.
    « Ce que l'on conçoit bien s'énonce clairement, et les mots pour le dire arrivent aisément ». (Nicolas Boileau)
    À la maison comme au bureau, j'utilise la suite Linux Mageïa !

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

Discussions similaires

  1. supprimer une instance SQL server
    Par PickEpique dans le forum MS SQL Server
    Réponses: 0
    Dernier message: 01/04/2010, 21h31
  2. Supprimer l'instance créée à l'init c'est possible ?
    Par quiscoul dans le forum Général Python
    Réponses: 14
    Dernier message: 16/01/2009, 19h23
  3. Réponses: 9
    Dernier message: 30/12/2008, 19h21
  4. [POO] supprimer une instance
    Par Sh4dow49 dans le forum Langage
    Réponses: 3
    Dernier message: 20/09/2008, 16h53
  5. Réponses: 1
    Dernier message: 26/04/2006, 13h33

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