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.