Hi Matt, thanks , I think the main
problem then is the column "author". It is not an FK to 1 table
but rather to 4 (or if I got it right probably to 2) tables. In
order for mapperdao to work, the column should be an FK to 1 other
entity (or in database terms a FK to 1 single column and declared
so that referential integrity is achieved).
Thinking of it in terms of a query, you would have to do the query
in 2 steps, because you can't join on "author" and one of the
relevant tables until you know what's in invites.type.
In terms of the domain model, it makes sense. Now how can this be
mapped to tables?
One way to do this, without loosing referential integrity, type
safe and also to have the ability to use mapperdao's query api is
- map InviteT hierarchy into 1 table, but the table will contain
a. tournament_id (FK to tournament)
b. event_id (FK to event)
c. team_id (FK to team)
d. user_id (FK to user)
Note, a,b,c,d seems like a 1-to-1 relationship to me, according to
The mapping could be like:
val tournament = onetoone(TournamentEntity) option( _.author match
case t:Tournament => Some(t)
- you might keep invites.type but it is not necessary any more.
In the constructor you can check if you got a tournament or an
event, a team or a user, and construct the relevant subclass of
- now you can use InviteTEntity.tournament in queries (and
Note that you will need 1 entity object for each of Tournament,
Event,Teams , Users. But only 1 entity object for all InviteT's.
Is that something close to what you're looking for?