Hi Jeppe,

I did something similar with the following code:

trait HasUser [T <: HasUser[T]] extends KeyedMapper[Long, T]{
  self: T=>
    object user extends MappedLongForeignKey(this, User) {
          override def dbColumnName = "user_id"
    }
}

trait HasUserMetaMapper[T <: HasUser[T]] {
    self: T with LongKeyedMetaMapper[T] =>

    def findAllByUserId(uid:Long) = findAll(By(user,uid))
}

On Aug 24, 5:31 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
> Hi,
>
> I'm trying to create some mixins to be applied to mapper/metamapper
> objects to be used when objects are always owned by an account
> (ie. a multi tenant db)
>
> The mapper parts works fine:
>
> trait OwnedEntity {
>   self: BaseMapper =>
>
>   object account extends MappedLongForeignKey(this.asInstanceOf[MapperType], 
> Account) {
>     override def dbColumnName = "account_id"
>     override def dbDisplay_? = false
>     override def defaultValue = Account.currentAccount
>   }
>
> }
>
> but I can't seem to figure out the correct type bounds to create a
> MetaMapper mixin that uses the above. Simple example with just a findMap
> that finds all the entities owned by the current account:
>
> trait MetaOwnedEntity[A <: OwnedEntity] {
>     self: A with MetaMapper[A] =>
>
>     // Find and map all entities owner by current account
>     def findMap[T](f: MapperType => Box[T]) : List[T] = findMap(By(account, 
> Account.currentAccount))(f)
>
> }
>
> this fails compilation (1.1-SNAPSHOT), any clues?
>
> EntityUtils.scala:23: error: overloaded method value apply with alternatives 
> [O <: net.liftweb.mapper.Mapper[O],T,Q <: 
> net.liftweb.mapper.KeyedMapper[T,Q]](net.liftweb.mapper.MappedForeignKey[T, 
> O,Q],net.liftweb.util.Box[Q])net.liftweb.mapper.Cmp[O,T] <and> [O <: 
> net.liftweb.mapper.Mapper[O],T,Q <: 
> net.liftweb.mapper.KeyedMapper[T,Q]](net.liftweb.mapper.MappedForeignKey[T, 
> O,Q],Q)net.liftweb.mapper.Cmp[O,T] <and> [O <: 
> net.liftweb.mapper.Mapper[O],T,U](net.liftweb.mapper.MappedField[T,O],U)(im 
> plicit (U) => T)net.liftweb.mapper.Cmp[O,T] cannot be applied to 
> (MetaOwnedEntity.this.account.type,Long)
>     def findMap[T](f: MapperType => Box[T]) : List[T] = findMap(By(account, 
> Account.currentAccount))(f)
>
> /Jeppe
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to