-->
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: @OneToOne with cross tables
PostPosted: Tue Sep 18, 2012 2:12 pm 
Newbie

Joined: Tue Sep 18, 2012 12:10 pm
Posts: 1
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


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.