[Lift] Re: Where did Mapper's MappedManyToMany go?
Can I see the whole Mapper definition? Also, it needs more parameters. - Jim Barrowsjim.barr...@gmail.com wrote: On Mon, Nov 9, 2009 at 10:12 PM, Naftoli Gugenheim naftoli...@gmail.comwrote: MappedManyToMany is defined in the ManyToMay trait, which your mapper should extend. I found it in the code (see link below). I'm also following this tutorialhttp://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relationshipsand the MappedOneToMany class also can't be found. The error is: /home/jimbarrows/workspaces/path/to/code/model/D20Character.scala:38: error: not found: type MappedManyToMany object characterClasses extends MappedManyToMany(this, CharacterClass) ^ and the code is: import _root_.net.liftweb.mapper._ /**Bunch of other stuff here. object list extends MappedManyToMany(this, ListClass) - Jim Barrowsjim.barr...@gmail.com wrote: I can see it here http://github.com/dpp/liftweb/blob/1.1-M7/lift-persistence/lift-mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala in the 1.1M7 code base, but can't find it in the jar that Maven downloaded. The trait is there, but the Mapped version is missing. The same for MappedOneToMany as well. -- James A Barrows -- James A Barrows --~--~-~--~~~---~--~~ 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: Where did Mapper's MappedManyToMany go?
So that should be class D20Character extends ... with ManyToMany { - Jim Barrowsjim.barr...@gmail.com wrote: On Tue, Nov 10, 2009 at 7:39 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: Can I see the whole Mapper definition? Also, it needs more parameters. Yes, I know. but if the classloader can't find the class, it doesn't really matter. package com.nsfw.d20evolution.model import _root_.net.liftweb.mapper._ import net.liftweb.http.RedirectResponse import net.liftweb.sitemap.Loc.If class D20Character extends LongKeyedMapper[D20Character] with IdPK{ def getSingleton = D20Character object owner extends MappedLongForeignKey (this, User) { override def dbIndexed_? = true } object name extends MappedPoliteString(this,128) object strength extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object dexterity extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object constitution extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object intelligence extends MappedInt(this) with AbilityModifier with BonusSpells{ def modifier : Int = super.modifier(this.intValue) def bonusSpells : Option[List[Int]] = super.bonusSpells(this.intValue) } object wisdom extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object charisma extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object characterClasses extends MappedManyToMany(this, CharacterClass) def levelFor(className : String) : int = for (charClass - characterClasses.asInstanceOf[List[CharacterClass]]; if ( charClass.classInfo.name == className))yield charClass.level def characterLevel = for (charClass - characterClasses.asInstanceOf[List[CharacterClass]]){ total += charClass.level } } object D20Character extends D20Character with LongKeyedMetaMapper[D20Character] with CRUDify[Long, D20Character] { def findByName(owner: User, name: String) : List[D20Character] = D20Character.findAll(By(D20Character.owner, owner.id.is), By(D20Character.name, name)) //override def findForListParams: List[QueryParam[D20Character]] = By(D20Character.owner, User.currentUser) :: super.findForListParams // override def showAllMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams // // override def createMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams // // override def viewMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams // // override def editMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams override def save = { this.owner(User.currentUser) super.save; } } - Jim Barrowsjim.barr...@gmail.com wrote: On Mon, Nov 9, 2009 at 10:12 PM, Naftoli Gugenheim naftoli...@gmail.com wrote: MappedManyToMany is defined in the ManyToMay trait, which your mapper should extend. I found it in the code (see link below). I'm also following this tutorial http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relationships and the MappedOneToMany class also can't be found. The error is: /home/jimbarrows/workspaces/path/to/code/model/D20Character.scala:38: error: not found: type MappedManyToMany object characterClasses extends MappedManyToMany(this, CharacterClass) ^ and the code is: import _root_.net.liftweb.mapper._ /**Bunch of other stuff here. object list extends MappedManyToMany(this, ListClass) - Jim Barrowsjim.barr...@gmail.com wrote: I can see it here http://github.com/dpp/liftweb/blob/1.1-M7/lift-persistence/lift-mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala in the 1.1M7 code base, but can't find it in the jar that Maven downloaded. The trait is there, but the Mapped version is missing. The same for MappedOneToMany as well. -- James A Barrows -- James A Barrows -- James A Barrows --~--~-~--~~~---~--~~ 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: Where did Mapper's MappedManyToMany go?
Since MappedOneToMany does not extend MappedField, in order for the entity to manage its MappedOneToMany's it must extend ManyToMany. This allows saves and deletes to be propogated, for example. When you add and remove elements from the MappedManyToMany, those changes don't happen in the database until the MappedManyToMany is saved. It's saved automatically when you save the mapper. Also, when you delete the mapper it will delete the join table record. **Thus it is very important that both sides of the many-to-many relationship have ManyToMany and MappedManyToMany**, so that if you delete from either side the join table will retain its integrity, as I have recently come to realize. - Jim Barrowsjim.barr...@gmail.com wrote: That makes no sense. Ill give it a try. Sent on the Now Network� from my Sprint® BlackBerry -Original Message- From: Naftoli Gugenheim naftoli...@gmail.com Date: Tue, 10 Nov 2009 06:56:23 To: jim.barr...@gmail.com; liftweb@googlegroups.com Subject: Re: [Lift] Where did Mapper's MappedManyToMany go? So that should be class D20Character extends ... with ManyToMany { - Jim Barrowsjim.barr...@gmail.com wrote: On Tue, Nov 10, 2009 at 7:39 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: Can I see the whole Mapper definition? Also, it needs more parameters. Yes, I know. but if the classloader can't find the class, it doesn't really matter. package com.nsfw.d20evolution.model import _root_.net.liftweb.mapper._ import net.liftweb.http.RedirectResponse import net.liftweb.sitemap.Loc.If class D20Character extends LongKeyedMapper[D20Character] with IdPK{ def getSingleton = D20Character object owner extends MappedLongForeignKey (this, User) { override def dbIndexed_? = true } object name extends MappedPoliteString(this,128) object strength extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object dexterity extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object constitution extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object intelligence extends MappedInt(this) with AbilityModifier with BonusSpells{ def modifier : Int = super.modifier(this.intValue) def bonusSpells : Option[List[Int]] = super.bonusSpells(this.intValue) } object wisdom extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object charisma extends MappedInt(this) with AbilityModifier { def modifier : Int = super.modifier(this.intValue) } object characterClasses extends MappedManyToMany(this, CharacterClass) def levelFor(className : String) : int = for (charClass - characterClasses.asInstanceOf[List[CharacterClass]]; if ( charClass.classInfo.name == className))yield charClass.level def characterLevel = for (charClass - characterClasses.asInstanceOf[List[CharacterClass]]){ total += charClass.level } } object D20Character extends D20Character with LongKeyedMetaMapper[D20Character] with CRUDify[Long, D20Character] { def findByName(owner: User, name: String) : List[D20Character] = D20Character.findAll(By(D20Character.owner, owner.id.is), By(D20Character.name, name)) //override def findForListParams: List[QueryParam[D20Character]] = By(D20Character.owner, User.currentUser) :: super.findForListParams // override def showAllMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams // // override def createMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams // // override def viewMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams // // override def editMenuLocParams = If(User.loggedIn_? _, RedirectResponse(/user_mgt/login)) :: super.editMenuLocParams override def save = { this.owner(User.currentUser) super.save; } } - Jim Barrowsjim.barr...@gmail.com wrote: On Mon, Nov 9, 2009 at 10:12 PM, Naftoli Gugenheim naftoli...@gmail.com wrote: MappedManyToMany is defined in the ManyToMay trait, which your mapper should extend. I found it in the code (see link below). I'm also following this tutorial http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relationships and the MappedOneToMany class also can't be found. The error is: /home/jimbarrows/workspaces/path/to/code/model/D20Character.scala:38: error: not found: type MappedManyToMany object characterClasses extends MappedManyToMany(this, CharacterClass) ^ and the code is: import _root_.net.liftweb.mapper._ /**Bunch of other stuff here. object list extends
[Lift] Re: Where did Mapper's MappedManyToMany go?
MappedManyToMany is defined in the ManyToMay trait, which your mapper should extend. - Jim Barrowsjim.barr...@gmail.com wrote: I can see it herehttp://github.com/dpp/liftweb/blob/1.1-M7/lift-persistence/lift-mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scalain the 1.1M7 code base, but can't find it in the jar that Maven downloaded. The trait is there, but the Mapped version is missing. The same for MappedOneToMany as well. -- James A Barrows --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---