Hi,
Is there any way I can map properties of a relationship to one of the involved entities?
For instance
table Person (
id int
name string
eventId int
)
table Event (
id int
eventName string
someOtherProps string
)
table Person_Event (
personId int
eventId int
isPresent boolean //this is the extra property, notes whether the person is present at the event
primary key(personId, eventId)
foreign key(personId) references Person(id)
foreign key(eventId) reference Event(id)
)
and then have it map so that when I create my EventEntity
object EventEntity extends Entity[Int, SurrogateIntId, Event] {
val id = key("id") autogenerated (_.id)
val name = column("eventName") to (_.name)
val other = column("someOtherProps") to (_.other)
val isPresent = ??? //map the extra property on the linked table here
val persons = manytomanyreverse(PersonEntity) to (_.persons)
...
}
--
You received this message because you are subscribed to the Google Groups "mapperdao" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapperdao+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
My apologies, I hastily typed out that code and I realize it doesn’t make much sense now :)
First, a description:
Users can attend multiple Events, and Events can contain multiple Users. The relationship between the two is many-to-many. I would like to include extra information about each individual relationship between an Event
and a User
though — such as whether the User
is present at the Event
(isPresent
)
Here are more domain objects
class User(val id: Int, val email: String, val createdDate: DateTime, val events: Set[Event]) {
}
class Event(val id: Long, val name: String, val eventType: JoinType.Value, val description: EventDetails, val users: Set[User]) {
}
Initially I thought I would like to have an isPresent
field for each Event
but after doing some research this does not seem possible(and really doesn’t make sense), what I really trying to achieve is described here, Mapping a Join Table with Additional Columns.