Note that there are some explanatory texts on larger screens.

plurals
  1. POhibernate and Java.util.set problem
    primarykey
    data
    text
    <p>i 'm trying the hibernate tutorials from their main site and wanted to change thing a bit to know how many to many relationship work with java.util.set interface.My mappings are correct and i can insert in and from the tables EVENT, PERSON and the mapping table PERSON_EVENT.Now i've inserted some dummy values in the tables and add their mappings in the mapping table.I wanted to display all the events of all the person who are register to an event or more. with this code :</p> <pre><code> public void ShowPersonEvents() { Person aperson; Event anEvent; Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); List&lt;Person&gt; persons = session.createQuery("from Person").list(); for(int i =0; i&lt; persons.size(); i++) { aperson = (Person) persons.get(i); Set a = aperson.getEvents(); // String[] events = (String[])a.toArray(new String[a.size()]); // for (String e : events) // { // System.out.println(aperson.getLastname()+" is registerd to the" + e); // // } Iterator it = a.iterator(); while(it.hasNext()) { System.out.println(aperson.getLastname()+" is registerd to the" +(String) it.next().toString()); } // System.out.println(); } session.getTransaction().commit(); } } </code></pre> <p>so when i run is the who the correct number of rows but instead of show for example rows like :</p> <blockquote> <p>Joseph is registered to the opensouce event </p> </blockquote> <p>it's rather showing something like : </p> <blockquote> <p>Joseph is registered to the domain.Event@18a8ce2 </p> </blockquote> <p>this is the format mypackagename.myclassname@something. when i comment the iterator part ant uncomment the casting to an string array i have an exception:arraystoreexception. I'm kind of lost a bit.I can't see what is wrong here.Please can you have a look and tell me what i did wrong?Thanks for reading.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload