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.  [ 3 posts ] 
Author Message
 Post subject: many-to-many, set et JSF
PostPosted: Wed Apr 19, 2006 12:36 pm 
Newbie

Joined: Wed Apr 19, 2006 12:15 pm
Posts: 2
Bonjour, j'ai un problème de récupération d'objets persistants dans Hibernate.

Je possède 3 tables

events {events_id,title,...}
person {person_id,age,...}
person_event {person_id,event_id}

mappées comme suit :

(Classe Person)

Code:
<hibernate-mapping>
  <class name="events.Person" table="person" schema="public">
    <id name="personId" type="long">
      <column name="person_id" /><generator class="increment" />
    </id> ...
    <set name="events" table="PERSON_EVENT" lazy="false">
      <key column="PERSON_ID"/>
      <many-to-many column="EVENT_ID" class="events.Events"/>
    </set>
  </class>
</hibernate-mapping>



(Classe Events)

Code:
<hibernate-mapping>
  <class name="events.Events" table="events" schema="public"
    <id name="eventsId" type="long">
      <column name="events_id" /> <generator class="increment" />
    </id> ...
    <set name="personnes" table="PERSON_EVENT">
      <key column="EVENT_ID"/>
      <many-to-many column="PERSON_ID" class="events.Person"/>
    </set>
  </class>
</hibernate-mapping>



Le mapping fonctionne parfaitement, les insertions et suppressions ne posent pas de problèmes.
Par contre lorsque j'essaye de récupérer une instance de ma classe Person :

Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); this.model.setDatas(session.createQuery("from Person").list()); this.personne = (Person) model.getDatas().get(0); session.getTransaction().commit();


Il remplit apparemment la propriété events de la classe avec des objets de type PersistentSet car je reçois l'erreur :

Code :

javax.servlet.ServletException: javax.servlet.jsp.JspException: Error getting property 'eventsId' from bean of type org.hibernate.collection.PersistentSet


L'erreur à lieu lorsque ma JSF tente d'accéder aux évènements contenus dans l'instance de Person:


Code:
<h:dataTable binding="#{personctrl.view.dataTable}" value="#{personctrl.personne.events}" var="ev" border="1">
  <h:column>
    <f:facet name="header">
      <h:outputText value="Identifiant" />
    </f:facet>
    <h:outputText value="#{ev.eventsId}" />
  </h:column>
  ...



J'espère avoir été suffisament précis ... merci de votre aide.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 19, 2006 6:01 pm 
Newbie

Joined: Wed Apr 19, 2006 2:51 pm
Posts: 16
A ma connaissance "org.hibernate.collection.PersistentSet" n'est pas un type de Collection accepté par les DataTable de JSF !

Pour instancier une DataTable JSF tu dois utiliser un Array[], une List (ArrayList,...) ou une Map (HashMap ...) ;

J'espère que cela t'aidera !

--------------------------------------------------------------------------
Cheers,
Laurent

Thanks to rate in case it helped !


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 20, 2006 4:43 pm 
Newbie

Joined: Wed Apr 19, 2006 12:15 pm
Posts: 2
Effectivement j'ai trouvé la solution juste avant de lire ton post. Merci beaucoup !


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.