• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate: ArryaList Collection associations are not working

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have 2 POJOs: Menugroup, Catgroup. Menugroup has one-to-many replationship with Catgroup. Evenything works fine when I declared Catgroups as java.util.HashSet. I started getting the problem when I changed the collections type to java.util.List.

Getting the below exception:


Menugroup.java POJO is below:-




Catgroup.java POJO is below;-




Menugroup.hbm.xml is below:-




Catgroup.hbm.xml is below:-




This is my jave code snippet tries pull the data from DB:

List<?> menuGroups = dao.getSession().createCriteria(Menugroup.class).list;


Hibernate generates the below SQLs in the console:




I don't know, from where hibernate adds this column 'catgroups0_.idx' in the SQL since I never defined this column anywhere. The same thing works fine for Set Collections, but it is not working for java.util.List, this is really strange, I don't know whether I am really missing some thing or this a BUG in hibernate ?. Could any one please help me.

Thanks
Sarav
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it problem with your mapping xml file.

I THINK list element requires <list-index column="yourcolumnName"/> for indexing.Just add this and see I hope it will be working.
 
Saravanan Vijayappan
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It worked, Thank you buddy !!!
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indeed, SQLGrammarException problems most often boil down to some type of mapping problem.

-Cameron McKenzie
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Saravanan,

Could you please post the code you have used/developed to persist the said objects using one to many relation.

Thanks
 
I think I'll just lie down here for a second. And ponder this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic