Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7550667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:16:21+00:00 2026-05-30T10:16:21+00:00

UPDATE: Changed the samples to reflect my current situation Fairly new to lift and

  • 0

UPDATE: Changed the samples to reflect my current situation

Fairly new to lift and I am trying to create a model for my application. Since I want to keep things in the spirit of DRY I want to use trait mixins to specify some of the fields in my model. For instance, I have a Person trait which I mixin to my Employee class:

trait Person[T <: LongKeyedMapper[T]] extends LongKeyedMapper[T]{
  self: T =>
  object firstName extends MappedString[T](this, 50)
  object lastName extends MappedString[T](this, 50)
  object civicRegNumber extends MappedString[T](this, 12)
}

class Employee extends IdPK with OneToMany[Long, Employee] with Person[Employee] {
  def getSingleton = Employee

  object contactInfos extends MappedOneToMany(EmployeeContactInfo, EmployeeContactInfo.person) 
}

object Employee extends Employee with LongKeyedMetaMapper[Employee] 

As can be seen I have a contactInfos many to one mapping in the Employee. It looks like:

trait PersonContactInfo[T <: LongKeyedMapper[T],P <: Person[P]] extends LongKeyedMapper[T] {
  self: T =>
  object email extends MappedEmail[T](this, 80)
  def personMeta:P with LongKeyedMetaMapper[P]
  object person extends LongMappedMapper[T,P](this, personMeta)
}

class EmployeeContactInfo extends IdPK with PersonContactInfo[EmployeeContactInfo, Employee] {
  def getSingleton = EmployeeContactInfo
  val personMeta = Employee

}
object EmployeeContactInfo extends  EmployeeContactInfo with LongKeyedMetaMapper[EmployeeContactInfo]

This seems to work, but I would like to move the contactInfos object into my Person trait. However, I can’t figure out how to achieve this… Is it at all possible to inherit OneToMany mappings from traits? Any help welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:16:22+00:00Added an answer on May 30, 2026 at 10:16 am

    After a few tries I got this to work by separating the trait which does the OneToMany mapping of Person to PersonContactInfo. This is how it looks now

    trait Person[T <: Person[T]] extends LongKeyedMapper[T]{
      self: T =>
      object firstName extends MappedString[T](this, 50)
      object lastName extends MappedString[T](this, 50)
      object civicRegNumber extends MappedString[T](this, 12)
    }
    
    trait PersonToPersonContacts[P <: Person[P], PCI <: PersonContactInfo[PCI, P]] extends OneToMany[Long,P] {
      self: P =>
      def contactInfoMeta:LongKeyedMetaMapper[PCI] with PCI
      object contactInfos extends MappedOneToMany(contactInfoMeta, contactInfoMeta.person)
    }
    
    class Employee extends IdPK with Person[Employee]  with PersonToPersonContacts[Employee, EmployeeContactInfo] {
      def getSingleton = Employee
      override def contactInfoMeta = EmployeeContactInfo
    }
    object Employee extends Employee with LongKeyedMetaMapper[Employee] 
    

    and my PersonContactInfo now looks like:

    trait PersonContactInfo[T <: LongKeyedMapper[T],P <: Person[P]] extends LongKeyedMapper[T] {
      self: T =>
      object email extends MappedEmail[T](this, 80)
      def personMeta:P with LongKeyedMetaMapper[P]
      object person extends LongMappedMapper[T,P](this, personMeta)
    }
    
    class EmployeeContactInfo extends IdPK with PersonContactInfo[EmployeeContactInfo, Employee] {
      def getSingleton = EmployeeContactInfo
    
      val personMeta = Employee
    
    }
    object EmployeeContactInfo extends  EmployeeContactInfo with LongKeyedMetaMapper[EmployeeContactInfo]
    

    Still not sure if this is the way to solve this, but ity does the job 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: Facebook's API has changed a lot since this question was posted. This question
What is a correct way to update model when view changed. Is it need
I'm trying to update/change contact ringtone using this code: ContentValues values = new ContentValues();
I am trying to update table Original with the values in Final. I'm new
The footer should update with current time and hour when a new Item added
I have been trying to create an application to go through our database at
I am trying to update a small area in my web page.I just want
UPDATE: I've changed the wording of the question. Previously it was a yes/no question
I have a listview which has its datasource changed after update of a search
If an entities properties have changed in a controller action and Update/SaveChanges is not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.