On Thu, Dec 10, 2009 at 10:00 AM, Joern <joern.bernha...@gmx.net> wrote:

> I believe it's a bit more complicated than that. I made one platform
> where you register and login to a User (let's call it UserA). Then I
> made some sub-platforms, which all have their own type of User (so
> many different "UserB"). All of the user types inherit from
> "InstanceUser" and all UserB have a reference to UserA. My problem is,
> I have an Admin, who has not registered to one of the sub-platforms
> and therefore no UserB. I want to let him edit or create, for example,
> news entries on that sub-platform anyways. To make sure, to select the
> right person (and get the right name of it), I wanted to use the
> Boolean value, saving whether it is one of the admins or one of the
> users of the sub-platform.
>
> I think your solution would be a workaround, but I would need to
> create both MappedLongForeignKeys everytime I need them and the same
> with the getRef/setRef methods (I'd make only one setRef method and
> pattern-match the type in there). I wouldn't be able to "separate" it
> out of my code. I want to separate it, because sometimes I need the
> same thing twice in one model. For example a NewsEntry: The author
> could be either an user with or without an sub-platform account and
> the same happens for someone who made the last edit of the news. Then
> I'd need four methods and four ForeignKeys instead of just two objects
> that extend "MappedUser" or something similar. I see many copy & paste
> errors coming to me, if I don't have a way to separate that
> functionality.
>
> Did this clarify my problem a bit?
>

Actually, you confused me a whole lot.  How about you give us the schema
that you're proposing to use?


>
> Thanks,
> Joern
>
> On Dec 10, 6:17 pm, Derek Chen-Becker <dchenbec...@gmail.com> wrote:
> > IMHO this doesn't sound like an ideal way to do this. At a high level
> what
> > are you trying to do? Is this a legacy DB or starting from scratch? If I
> had
> > to do something like this I would instead use something like
> > MappedLongForeignKey so that you have a direct reference to the other
> tables
> > instead of having to do it manually. Something like:
> >
> > class C extends LongKeyedMapper[C] with IdPK {
> >   def getSingleton = C
> >
> >   object refA extends MappedLongForeignKey(this,A)
> >   object refB extends MappedLongForeignKey(this,B)
> >
> >   def getRef = refA.obj or refB.obj
> >
> >   def setRef(obj : A) = refA(obj); refB(Empty)
> >   def setRef(obj : B) = refB(obj); refA(Empty)
> >
> > }
> >
> > Derek
> >
> > On Wed, Dec 9, 2009 at 9:44 PM, Joern <joern.bernha...@gmx.net> wrote:
> > > Hi there,
> >
> > > I want to create a MappedField, which has one column as Type Long and
> > > another column as Type Boolean, but I don't know, what I should put
> > > into "dbFieldClass" and/or targetSQLType. If I look at MappedPassword
> > > for example, I just see classOf[String] or Types.VARCHAR, which
> > > somehow makes sense, because all columns of the MappedPassword are
> > > Strings. How can I create such a MappedField ?
> >
> > > Or maybe there is a completely different and/or better way to approach
> > > my problem:
> > > I have two tables (A and B), which are represented by my own mapper
> > > classes having IdPK.
> > > In a third table (let's call it C), I want to reference an instance of
> > > A or B in table C. As mentioned above, I want to say for example that
> > > Boolean "false" means look in table A for the Long (=index) and "true"
> > > -> look in table B.
> >
> > > Any tips, pointers or links to more documentation about multi-column
> > > mappedfields? :)
> >
> > > Thanks,
> > > Joern
> >
> > > --
> >
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Lift" group.
> > > To post to this group, send email to lift...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> <liftweb%2bunsubscr...@googlegroups.com<liftweb%252bunsubscr...@googlegroups.com>
> >
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/liftweb?hl=en.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this group, send email to lift...@googlegroups.com.
> To unsubscribe from this group, send email to
> liftweb+unsubscr...@googlegroups.com<liftweb%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/liftweb?hl=en.
>
>
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://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 lift...@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