Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Al Hobbs
  • salvin francis

Hibernate: Many-to-many bidirectional mapping. Stack Overflow

Posts: 1
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am trying a Many-to-many bidirectional mapping.

my code is

Session session = HibernateUtil.getSessionFactory().openSession();
Transaction tr = null;
ArrayList<StudentInfo> slist = new ArrayList<StudentInfo>();
ArrayList< CourseInfo>course = new ArrayList<CourseInfo>();
tr = session.beginTransaction();
slist = (ArrayList<StudentInfo>)session.createQuery("from student.StudentInfo where sid = " +sid).list();
if(slist == null)
System.out.println("slist = null");
System.out.println("slist not null");
StudentInfo stud = slist.get(0);
for(int i = 0; i < co.length; i++)
int cid = Integer.parseInt(co[i]);
course = (ArrayList<CourseInfo>)session.createQuery("from course.CourseInfo where cid = " +cid).list();
CourseInfo cou = course.get(0);

This code works fine that entry is made in database but while printing course it gives Stack over flow error

1) i am printing student info with course where course is set it gives error when it encounter getCourse() method

Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"co" that is in your for loop is not defined in your code. Please show us all your code and put it in a code block so we can read it easier.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic