I would suggest having a third entity with indexed references to both entities. That way, you could easily query for every student in a category, or for every category of a student.
@Entity
public class Student { /*...*/ }
@Entity
public class Category { /*...*/ }
@Entity
public class StudentCategory {
@Id
private Long id;
@Index
private Ref<Student> student;
@Index
private Ref<Category> category;
/*...*/
}
We have a similar setup in our GAE applications, and it has served us well.