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

Collection et Stream Java Discussion :

pb HashMap nulle


Sujet :

Collection et Stream Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Août 2004
    Messages
    86
    Détails du profil
    Informations forums :
    Inscription : Août 2004
    Messages : 86
    Par défaut pb HashMap nulle
    Bonjour,

    J'ai deux méthodes qui manipulent des HashMap ,la première(deleteVoyagesPrev) fait appel à la deuxième(findVoyageStatSupprById),cette dernière reçoit le résultat d'une requête Sql qui renvoit deux BigDecimal(min et max).

    Le problème est que la HashMap a tjs la valeur null et je comprends pas pourqoui ?

    Si vous pouvez m'aider,ça sera gentil de votre part.

    Merci d'avance.

    voici les codes:

    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
     
    public void deleteVoyagesPrev(ILieu origine, ILieu destination,
    			String clientOrigine, String clientDestination, Date debutPeriode,
    			Date finPeriode, int nombreASupprimer) throws DaoException {
    		SqlMapClient sqlMap = SqlManager.getSqlMapInstance();
    		Map<String, Object> map = new HashMap<String, Object>();
    		Map<String, Object> minMaxMap= new HashMap<String, Object>();
    		map.put("param", nombreASupprimer);
    		if (origine != null)
    			map.put("idLieuOrigine", origine.getIdLieu());
    		if (destination != null) {
    			map.put("idLieuDestination", destination.getIdLieu());
    		}
    		map.put("clientOrigine", clientOrigine);
    		map.put("clientDestination", clientDestination);
    		if (debutPeriode != null) {
    			map.put("dateDebutPeriode", DateHelper.formatDate(debutPeriode));
    		}
    		if (finPeriode != null) {
    			map.put("dateFinPeriode", DateHelper.formatDate(finPeriode));
    		}
    		try {
    			 minMaxMap = findVoyageStatSupprById(origine,
    					destination, clientOrigine, clientDestination,
    					debutPeriode, finPeriode, nombreASupprimer);
    			System.out.println("min : " + minMaxMap.get("min_id") + " max :"
    					+ minMaxMap.get("max_id"));
    			map.put("min", minMaxMap.get("min_id"));
    			map.put("max", minMaxMap.get("max_id"));
    			sqlMap.update("Voyage.deleteVoyageStat", map);
    		} catch (SQLException e) {
    			throw new DaoException(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
     
     
    public Map<String, Object> findVoyageStatSupprById(ILieu origine,
    			ILieu destination, String clientOrigine, String clientDestination,
    			Date debutPeriode, Date finPeriode, int nombreASupprimer)
    			throws DaoException {
    		SqlMapClient sqlMap = SqlManager.getSqlMapInstance();
    		Map<String, Object> map = new HashMap<String, Object>();
    		Map<String,Object> mapBidon=new HashMap<String, Object>();
    		if (origine != null)
    			map.put("idLieuOrigine", origine.getIdLieu());
    		if (destination != null) {
    			map.put("idLieuDestination", destination.getIdLieu());
    		}
    		map.put("clientOrigine", clientOrigine);
    		map.put("clientDestination", clientDestination);
    		if (debutPeriode != null) {
    			map.put("dateDebutPeriode", DateHelper.formatDate(debutPeriode));
    		}
    		if (finPeriode != null) {
    			map.put("dateFinPeriode", DateHelper.formatDate(finPeriode));
    		}
    		try {
    			 mapBidon=(Map<String, Object>)(sqlMap.queryForObject(
    					"Voyage.findVoyageStatSupprById", map));
    			System.out.println("minbidon : " + mapBidon.get("min_id") + " maxbidon :"
    					+ mapBidon.get("max_id"));
     
    		} catch (SQLException e) {
    			throw new DaoException(e);
    		}
    		return mapBidon;
    	}
    Cdt,

  2. #2
    Membre Expert
    Avatar de CheryBen
    Inscrit en
    Mai 2005
    Messages
    1 599
    Détails du profil
    Informations personnelles :
    Âge : 43

    Informations forums :
    Inscription : Mai 2005
    Messages : 1 599
    Par défaut
    Bonjour, tu as une NullPointerException? où ça? quelle est la trace?
    Si tu n'as pas d'exception, où vois-tu que la HashMap est nulle? quelle HashMap?

  3. #3
    Membre confirmé
    Inscrit en
    Août 2004
    Messages
    86
    Détails du profil
    Informations forums :
    Inscription : Août 2004
    Messages : 86
    Par défaut
    bonjour,

    voici la trace obtenu :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    minbidon : null maxbidon :null
    min : null max :null
    p6spy - 23-05-08 10:19:02|0|1|statement
    	Prepared : update t_voyage   set  EST_ANNULE=1 where est_prevision=1 and est_annule=0 and id_voyage between ( and ) and rownum<=5
    	Sql : update t_voyage   set  EST_ANNULE=1 where est_prevision=1 and est_annule=0 and id_voyage between ( and ) and rownum<=5
    com.sncf.fret.swi.service.ServiceException: com.sncf.fret.swi.client.business.DaoException: com.ibatis.common.jdbc.exception.NestedSQLException:   
    --- The error occurred in queries/voyage.xml.  
    --- The error occurred while applying a parameter map.  
    --- Check the Voyage.deleteVoyageStat-InlineParameterMap.  
    --- Check the statement (update failed).  
    --- Cause: java.sql.SQLException: ORA-00936: missing expression
    merci.

    Cdt,

  4. #4
    Membre Expert
    Avatar de CheryBen
    Inscrit en
    Mai 2005
    Messages
    1 599
    Détails du profil
    Informations personnelles :
    Âge : 43

    Informations forums :
    Inscription : Mai 2005
    Messages : 1 599
    Par défaut
    C'est minbidon et maxbidon qui vallent null.
    Donc je pense que c'est ta requête qui n'est pas bonne ou n'a simplement aucun résultat.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    mapBidon=(Map<String, Object>)(sqlMap.queryForObject(
    					"Voyage.findVoyageStatSupprById", map));
    Cette requête renvoi une liste dans laquelle min_id et max_id ne sont pas présents.

  5. #5
    Membre confirmé
    Inscrit en
    Août 2004
    Messages
    86
    Détails du profil
    Informations forums :
    Inscription : Août 2004
    Messages : 86
    Par défaut pb résolu
    en fait oracle renvoit MAX_ID et MIN_ID et moi je mettais get("min_id") et get(max_id).C'est vrai que oracle ne différencie pas entre maj et min mais pour la HashMap si.

    merci pour votre aide.

    @+

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

Discussions similaires

  1. key hashMap null
    Par flora806 dans le forum Collection et Stream
    Réponses: 7
    Dernier message: 21/04/2008, 17h18
  2. souci HashMap, possedes valeurs nulles./ debutant
    Par Mobistar dans le forum Collection et Stream
    Réponses: 5
    Dernier message: 05/10/2007, 14h09
  3. clés et valeurs à null dans une HashMap typée
    Par Djakisback dans le forum API standards et tierces
    Réponses: 4
    Dernier message: 06/06/2006, 13h04
  4. [VB6] [BDD] Recordset et champ égal à Null
    Par Gr|ppen dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 07/03/2003, 10h00
  5. "ALTERER" une col. NULL en NOT NULL - Int
    Par Gandalf24 dans le forum SQL
    Réponses: 2
    Dernier message: 28/12/2002, 00h07

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