I have a cross table linking two tables, student can have many tickets, ticket only one student.
Like this:
Student(s_id) Ticket(t_id) Student_X_Ticket(sxt_id, s_id, t_id)
StudentDO @OneToMany(mappedBy="student") private Set<StudentXTicketDO> sxtSet;
TicketDO @OneToOne(mappedBy="ticket") private Set<StudentXTicket> sxiSet;
StudentXTicketDO @OneToOne @JoinColumn(name="t_id") private TicketDO ticket; @ManyToOne @JoinColumn(name="s_id") private StudentDO student;
If I have s-x-t and do s-x-t.getTicket(), I get the corresponding ticket. If I have the ticket and do ticket.getSxb(), I get null.
How do i set up the ticket side annotations to get the s-x-t back. Tried to add mappedBy by got a circular reference.
I'm trying to get all tickets for a student using something like student.getSxt()[looping thru].getTicket(). Also will need to work back to get the student for a ticket using ticket.getSxt().getStudent()
Will keep trying after I post...
Thanks
|