-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Problème de Map / HashMap avec XDoclet
PostPosted: Thu Jul 12, 2007 12:58 pm 
Newbie

Joined: Thu Jul 12, 2007 12:22 pm
Posts: 4
Bonjour,

Dans un modèle objets j'ai les relations suivantes :

    Correspondant (Object) -> MessageCounter(Object)
Tout fonctionne correctement.

Je viens de modifier ce modèle comme suit :

    Correspondant (Object) -> MessageCounter(Object)-> MissingMessages (HashMap)
Le fait d'avoir ajouter une HashMap (missingMessages) dans MessageCounter me pose deux problèmes :

    Le premier : lorsque j'effectue un "left join fetch de MissingMessages" j'obtiens l'exception suivante :
Code:
java.lang.NullPointerException
       at org.hibernate.loader.BasicLoader.isBag(BasicLoader.java:71)
        at org.hibernate.loader.BasicLoader.postInstantiate(BasicLoader.java:53)
        at org.hibernate.loader.hql.QueryLoader.<init>(QueryLoader.java:101)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:181)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
        at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:837)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:835)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:827)

En cherchant, je trouve le second problème :
    Au début de mon test, je persiste un objet correspondant qui devrait normalement persister la HashMap (cascade=all ou bien cascade = delete, persist), mais au final la table associée à la HashMap reste vide.
Il s'agit peut-être d'une erreur de mapping de ma part. Je joins le mapping à ce post.

Si vous avez des idées ou des suggestions sur la manière de résoudre ce problème je vous en remercie.

Pascal Goron.

Contexte : Spring 2.0, hibernate 3.2.cr4, XDoclet, Java 1.5

Ci-joint le mapping de la HashMap :

Code:
   /**
    * @hibernate.map table = "MSGCNT_MISSINGMSG" cascade="all"
    * @hibernate.key column="MessageCounterId" not-null="true"
    * @hibernate.index column="csnumber" type="long"
    * @hibernate.element column="timer" type="long"
    *
    * @return missingMessages
    */
   public Map<Long, Long>  getMissingMessages() {
      return this.missingMessages;
   }
La table MSGCNT_MISSINGMSG est correctement créée en base avec 3 colonnes MessageCounterId, CsNumber, Timer (Les contraintes sont OK)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 19, 2007 11:53 am 
Regular
Regular

Joined: Mon Apr 19, 2004 6:54 pm
Posts: 79
ca ne serait pas plutot les tags xdoclet suivant qu'il faudrait utiliser?
Code:
@hibernate.collection-key column="..."
@hibernate.collection-index column="..." ...
@hibernate.collection-element


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 20, 2007 8:07 am 
Newbie

Joined: Thu Jul 12, 2007 12:22 pm
Posts: 4
Bonjour et merci pour votre réponse,

Au cours de mes différents essais, j'ai également essayé ces tags et le comportement est identique - malheureusement.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 12:01 pm 
Newbie

Joined: Tue Dec 18, 2007 7:42 am
Posts: 19
Sorry I don't speak French, but I think I have the same problem:
http://forum.hibernate.org/viewtopic.php?p=2388341

Did you found a solution?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 12:17 pm 
Newbie

Joined: Thu Jul 12, 2007 12:22 pm
Posts: 4
TUD wrote:
Sorry I don't speak French, but I think I have the same problem:
http://forum.hibernate.org/viewtopic.php?p=2388341

Did you found a solution?


He,
I don't know if it is exactly the same problem, but i resolve it by changing a mapping file. I set the property 'Lazy=false' to force fetching this association all the time. It's CPU consumming but in my case no worry about this. (This object is not often requested)

I hope this help you.

Regards (and sorry for my poor english)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.