[Lift] Re: Two entity class map onto one DB table?

2009-10-27 Thread Ferdinand Chan

David,

Thanks for the quick reply.

Cheers,

Ferdinand

On Oct 28, 1:03 am, David Pollak 
wrote:
> Sure.
>
> Please remember to set the dbTableName in each of your classes to the same
> value:
>
> class Promotion extends LongKeyedMapper[Promotion] {
>   override def dbTableName = "shared_table_name"
>
>
>
>
>
> }
> On Tue, Oct 27, 2009 at 9:08 AM, Ferdinand Chan  wrote:
>
> > Hi,
>
> > I'm a newbie to Lift and still learning Lift by coding a pet project.
>
> > One question I have is about the Mapper.
>
> > For example, if I have two classes, say Promotion and Discount. They
> > are two different classes but having a one to one relationship to each
> > other, i.e. Each Promotion will have one Discount object and vise
> > versa.
>
> > If I model them in Lift by two classes and each of them extends from
> > LongKeyedMapper. Then each of them will be mapped to a DB table. Hence
> > I will have two tables created in DB.
>
> > Its it possible to setup or construct these two class such that in
> > code level, they will be two different classes but in DB level, they
> > are both mapped to a table.
>
> > For example, if Promotion have properties like name , expiry date and
> > Discount have properties like original price and discounted price. Can
> > they map to a table named PromotionDetails in DB with columns id,
> > name, expiry date, original_price and discounted_price ?
>
> > Thanks
>
> > Ferdinand
>
> --
> 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
-~--~~~~--~~--~--~---



[Lift] Re: Two entity class map onto one DB table?

2009-10-27 Thread Naftoli Gugenheim

Why do you want this? What's wrong with one Mapper or two tables?

-
Ferdinand Chan wrote:


Hi,

I'm a newbie to Lift and still learning Lift by coding a pet project.

One question I have is about the Mapper.

For example, if I have two classes, say Promotion and Discount. They
are two different classes but having a one to one relationship to each
other, i.e. Each Promotion will have one Discount object and vise
versa.


If I model them in Lift by two classes and each of them extends from
LongKeyedMapper. Then each of them will be mapped to a DB table. Hence
I will have two tables created in DB.

Its it possible to setup or construct these two class such that in
code level, they will be two different classes but in DB level, they
are both mapped to a table.

For example, if Promotion have properties like name , expiry date and
Discount have properties like original price and discounted price. Can
they map to a table named PromotionDetails in DB with columns id,
name, expiry date, original_price and discounted_price ?

Thanks

Ferdinand




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



[Lift] Re: Two entity class map onto one DB table?

2009-10-27 Thread David Pollak
Sure.

Please remember to set the dbTableName in each of your classes to the same
value:

class Promotion extends LongKeyedMapper[Promotion] {
  override def dbTableName = "shared_table_name"
}


On Tue, Oct 27, 2009 at 9:08 AM, Ferdinand Chan  wrote:

>
> Hi,
>
> I'm a newbie to Lift and still learning Lift by coding a pet project.
>
> One question I have is about the Mapper.
>
> For example, if I have two classes, say Promotion and Discount. They
> are two different classes but having a one to one relationship to each
> other, i.e. Each Promotion will have one Discount object and vise
> versa.
>
>
> If I model them in Lift by two classes and each of them extends from
> LongKeyedMapper. Then each of them will be mapped to a DB table. Hence
> I will have two tables created in DB.
>
> Its it possible to setup or construct these two class such that in
> code level, they will be two different classes but in DB level, they
> are both mapped to a table.
>
> For example, if Promotion have properties like name , expiry date and
> Discount have properties like original price and discounted price. Can
> they map to a table named PromotionDetails in DB with columns id,
> name, expiry date, original_price and discounted_price ?
>
> Thanks
>
> Ferdinand
>
>
> >
>


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