Hello good fellas! 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 :
public void ShowPersonEvents()
{
Person aperson;
Event anEvent;
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
List<Person> persons = session.createQuery("from Person").list();
for(int i =0; i< 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();
}
}
so when i run is the who the correct number of rows but instead of show for example rows like :
Joseph is registered to the opensouce event
it's rather showing something like :
Joseph is registered to the domain.Event@18a8ce2
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.