On Thu, Aug 27, 2009 at 10:26 AM, rstradling <ryanstradl...@gmail.com>wrote:

>
> With a parser combinator I wrote to parse .sql and it outputs scala
> orm files.


Care to share?  That'd be a pretty darned useful utility!


> Please note it is very specific to my needs (i.e. only
> works with certain grammars (INSERTS) but that particular grammar is
> all I needed to process at the time) but is written in a way that
> could be extended to the full grammar (at least that was my
> intent :)..


So... the problem is that objects in Scala are not subclassible.  What does
this mean?  For example:

trait Foo {
  object bar extends AnyRef
}

trait MyFoo extends Foo {
  override object bar {
    def cantDoIt = "sigh"
  }
}

Back in the Scala 2.5 days, there was some talk about allowing this to
happen, but it never did.  So, unfortunately, I can't think of a way for
your sql generator to create a superclass that could be subclassed and have
the effect that you want.

Sorry/


>
>
>
> On Aug 27, 1:09 pm, Naftoli Gugenheim <naftoli...@gmail.com> wrote:
> > How do you auto-generate them?
> >
> > On Thu, Aug 27, 2009 at 1:03 PM, rstradling <ryanstradl...@gmail.com>
> wrote:
> >
> > > I am using Lift 1.0 with the Mapper ORM module from Lift. I am a
> > > newbie to Scala and Lift.  I have auto-generated my ORM classes from
> > > a .sql file.  Given that these classes are auto-generated I would
> > > prefer not to edit them directly and provide additional functionality
> > > via inheritance.
> >
> > > Say I have the following...
> > > class StatGenerated extends LongKeyedMapper[StatGenerated] with IdPK {
> > >   def getSingleton = StatGenerated
> > >   object errors extends MappedLong(this)
> > >   object hits extends MappedLong(this)
> > >   object AB extends MappedLong(this)
> > > }
> >
> > > object StatGenerated extends StatGenerated with LongKeyedMetaMapper
> > > [StatGenerated] {
> > >   override def fieldOrder = List(errors, hits)
> > > }
> >
> > > class Statistics extends StatGenerated {
> > >   def GetBattingAverage(id : Long) : float = {
> > >                val stat = Stat.findByKey(id)
> > >                stat.hits/stat.AB
> > >   }
> > > }
> >
> > > Now what I would like to do is work with the Statistics class as my
> > > ORM object...
> > > But I believe everything that is ORM related is actually of type
> > > StatGenerated rather than Statistics.  i.e. findByKey will return me a
> > > StatGenerated rather than a Statistics class.  Is there any clever way
> > > around this that I am missing without either modifying the generated
> > > class or duplicating code?
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
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