0

I am trying to create a successful route for an entity that only has a composite key so that i may navigate to the default CRUD module's 'edit' interface.

Right now, I am successfully retrieving and displaying the list of all the club_admin's in the database, however when I try and navigate to the individual editing page of a club_admin, I receive the error of "no route."

The table in my database is:

create table club_admin  (
    club_id int not null,
    user_username varchar(25) not null,
    primary key (club_id,user_username),
    constraint fk_club_admin_club_id foreign key (club_id) references club(club_id), 
    constraint fk_club_admin_user_username foreign key (user_username) references user(user_username)
);

The code for the club_admin class is:

package models;

...

@Entity
@Table(name="club_admin")
public class ClubAdmin extends GenericModel
{

        @Id 
        @ManyToOne
        @JoinColumn(name="club_id", referencedColumnName="club_id")
        public Club club;

        @Id 
        @ManyToOne
        @JoinColumn(name="user_username", referencedColumnName="user_username")
        public User user;

        public ClubAdmin(Club club, User user)
        {
                this.club=club;
                this.user=user; 
        }

        ...
}

My guess is that the table/entity has no default id to use for the route, and thus fails. So my questions is how do I create a route, that uses the composite keys to navigate to the 'edit' page of the club_admin, without having to create a single primary key of type integer?

Thanks!

Luke
  • 776
  • 9
  • 24

1 Answers1

0

I found out that many to many relationships are represented by Set<class>. I should not have created the many to many class but instead should have created set of members (which represents an admin) variable on club or visa verse, depending on my needs. With this method, the many-to-many relation is created automatically. Also and there is no need to edit my routes.

Luke
  • 776
  • 9
  • 24