-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Having trouble with a collection
PostPosted: Tue May 26, 2009 6:23 pm 
Newbie

Joined: Fri May 22, 2009 5:40 pm
Posts: 1
I'm using Hibernate annotations to map a table with 2 columns. One column is an id and the other column is a foreign key, called catId to another table. The primary key is a unique combo of these two values. I'm usually not a fan of the "here's my code, what's wrong" posts but I'm really banging my head against the wall on this, it must just be something dumb I'm missing

fav_categories table
+----------+
| id | catId |
+----------+

categories table
+----------+
| id | name |
+----------+

Classes:

Code:
@Entity
@Table(name="fav_categories")
public class FavoriteCategories {

    @Id
    String userId;
   
    @OneToMany(fetch=FetchType.EAGER, cascade = CascadeType.ALL)
    @JoinColumn(name="id")
    List<Category> catIds;


Code:
@Entity
@Table(name = "categories")
public class Category {
    @Id
    private int id;
    private String name;


I'm trying to load the Categories for a user with
Code:
from FavoriteCategories where userId = ?


but the list is empty.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.