Then I would have two tables I suggest. But thank you nevertheless, it is not so important, I can live with fields mapping single columns ;). I only wanted to reduce some redundancy and was interested if it is possible to build such types.
On Oct 18, 12:23 am, David Pollak <feeder.of.the.be...@gmail.com> wrote: > On Sat, Oct 17, 2009 at 2:42 AM, hyperion <hyperion1...@googlemail.com>wrote: > > > > > I think my simple solution does not work... and the implementation of > > MappedPassword is not really easy to understand. I thought such > > classes > > would be nice for datatypes as Currency, Timespan etc... that appear > > everwhere > > in the application but where own tables are not useful. > > As I said, MappedPassword was a mistake. Supporting multiple columns > mapping to a single field was a mistake. It's hard stuff to get right. > > > > > > > > > The solution of Naftoli, I tried... but maybe I did something wrong: > > > trait MyMappedTimeSpan[T <:Mapper[T]]{ > > import net.liftweb.util._ > > import net.liftweb.http.S > > import xml.NodeSeq > > > object from extends MappedTime[T](this.asInstanceOf[T]) > > object to extends MappedTime[T](this.asInstanceOf[T]) > > > } > > > class Bericht extends LongKeyedMapper[Bericht] with IdPK with OneToMany > > [Long, Bericht]{ > > > override def getSingleton = Bericht > > object mittag extends MyMappedTimeSpan[Bericht] > > ... > > > If someone found a simple solution, please tell me so :) > > Your class should look like: > > class Bericht extends LongKeyedMapper[Bericht] with IdPK with OneToMany > [Long, Bericht] with MyMappedTimeSpan[Bericht] { > ... > > > > > > } > > > hyperion > > > On 16 Okt., 22:01, David Pollak <feeder.of.the.be...@gmail.com> wrote: > > > On Fri, Oct 16, 2009 at 9:42 AM, Naftoli Gugenheim <naftoli...@gmail.com > > >wrote: > > > > > I think there is support somewhere in the MappedField hierarchy for a > > > > MappedField that represents to database columns. Take a look at > > > > MappedPassword. > > > > Having a field represent two columns (as MappedPassword does) is a huge > > > piece of pain. I've made a ton of mistakes with Mapper, but the biggest, > > > nastiest shining hairball of a mistake was compound columns. Have I > > scared > > > anyone off using them yet? > > > > > ------------------------------------- > > > > harryh<har...@gmail.com> wrote: > > > > > Make MyMappedTimeSpan a trait: > > > > > trait MyMappedTimeSpan[T <:Mapper[T]](val owner: T) { > > > > object from extends MappedTime[MapperType](this.asIntanceOf > > > > [MatterType]) > > > > object to extends MappedTime[MapperType](this.asIntanceOf > > > > [MatterType]) > > > > } > > > > > And then use it like so: > > > > > class DBObject extends LongKeyedMapper[Bericht] with IdPK with > > > > MyMappedTimeSpan[DBObject] { > > > > } > > > > > -harryh > > > > > On Oct 16, 8:08 am, hyperion <hyperion1...@googlemail.com> wrote: > > > > > Hello, > > > > > > I tried this: > > > > > > class MyMappedTimeSpan[T <:Mapper[T]](val owner: T){ > > > > > import net.liftweb.util._ > > > > > import net.liftweb.http.S > > > > > import xml.NodeSeq > > > > > > val from = new MappedTime(owner) > > > > > val to = new MappedTime(owner) > > > > > } > > > > > > class DBObject extends LongKeyedMapper[Bericht] with IdPK { > > > > > > def getSingleton = Bericht > > > > > ... > > > > > object test extends MyMappedTimeSpan(this) > > > > > > } > > > > > > and bound this class with: > > > > > "from" -> bt.test.from.toForm, > > > > > "to" -> bt.test.to.toForm, > > > > > > In html: > > > > > <tr> > > > > > <td><bt:von/></td> > > > > > <td><bt:nach/></td> > > > > > </tr> > > > > > > Everything worked fine... except that my timespan is completely > > > > > ignored in the database ;). I think the reason is you use reflection > > > > > on class DBObject to find all values that should be stored in the > > > > > dabase?... but I have not inspected the source code jet... I am new > > to > > > > > lift and also to scala.... > > > > > > My Question: Is it possible to build such Datatypes based on two or > > > > > more DB-Fields of the single table...?... I think even they are > > > > > mapped to the "master"-DB-table, such types could be helpful... > > > > > > Greetz > > > > -- > > > Lift, the simply functional web frameworkhttp://liftweb.net > > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > > Follow me:http://twitter.com/dpp > > > Surf the harmonics > > -- > Lift, the simply functional web frameworkhttp://liftweb.net > Beginning Scalahttp://www.apress.com/book/view/1430219890 > Follow me:http://twitter.com/dpp > Surf the harmonics --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---