| Author |
Hibernate: ArryaList Collection associations are not working
|
Saravanan Vijayappan
Ranch Hand
Joined: Jan 02, 2007
Posts: 47
|
|
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
|
Cheers,<br />Sarav
|
 |
gopal venu
Ranch Hand
Joined: Jan 06, 2006
Posts: 55
|
|
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
Joined: Jan 02, 2007
Posts: 47
|
|
|
It worked, Thank you buddy !!!
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
Indeed, SQLGrammarException problems most often boil down to some type of mapping problem. -Cameron McKenzie
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
Konda Golamaru
Ranch Hand
Joined: Dec 12, 2005
Posts: 34
|
|
Hi Saravanan, Could you please post the code you have used/developed to persist the said objects using one to many relation. Thanks
|
 |
 |
|
|
subject: Hibernate: ArryaList Collection associations are not working
|
|
|