You could also do this: trait HasCreated [T <: HasCreated[T]] extends KeyedMapper[Long, T] { self: T => object created_at extends MappedDateTime(this) }
//mix into your meta object: trait HasCreatedMetaMapper[T <: HasCreated[T]] { self: T with LongKeyedMetaMapper[T] => import java.util.Date def findByCreated(startDate:Date, endDate:Date) = findAll(By_> (created_at, startDate), By_<(created_at, endDate)) } On Sep 3, 10:16 am, Giuseppe Fogliazza <g.foglia...@mcmspa.it> wrote: > As an alternative to asInstanceOf you could use explicit type > parameter in MappedField creation: > self:MapperType => > object xdatetime extends MappedDateTime[MapperType](this) > > On 3 Set, 09:19, Giuseppe Fogliazza <g.foglia...@mcmspa.it> wrote: > > > > > Unfortunately you cannot escape from asInstanceOf . Forcing > > self:MapperType the type of "this" will be TimeStamp with MapperType > > violating the constraint for the type of the first parameter of > > MappedDateTime :T <: Mapper[T]. > > > Regards > > Giuseppe > > > On 3 Set, 07:08, Naftoli Gugenheim <naftoli...@gmail.com> wrote: > > > > So I guess you can't escape the asInstanceOf. Can you successfully give > > > the trait a self-type of this: MapperType =>, or declare it to extend > > > Mapper[MapperType], without running into problems elsewhere? > > > > ------------------------------------- > > > > harryh<har...@gmail.com> wrote: > > > > I've been handling this with traits, for example I have something like > > > so: > > > > trait Timestamp[MapperType <: Mapper[MapperType]] { > > > object xdatetime extends MappedDateTime[MapperType](this.asInstanceOf > > > [MapperType]) > > > > // all sorts of utility functions for dealing with timestamps > > > > } > > > > Then I can do > > > > class Foo extends LongKeyedMapper[Foo] with IdPK with Timestamp[Foo] { > > > // additional fields that are Foo specific > > > > } > > > > I have quite a few traits similar to Timestamp at this point > > > corresponding to various fields that appear in lots of different > > > tables in my application. > > > > -harryh --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---