Thanks Derek, but unfortunately it only works halfway: I am able to set MAC address of my new Node and save it (returning true) and my MySQL database row is created, but the mac column is null.
Peter On Jul 21, 7:58 am, Derek Chen-Becker <[email protected]> wrote: > I think that this should work, but I haven't tested it: > > class Node extends KeyedMapper[String, Node] { > def getSingleton = Node > /* MAC address as primary key */ > def primaryKeyField = mac > object mac extends MappedStringIndex(this, 17) { > override def writePermission_? = true > override def dbDisplay_? = true > } > > } > > Note that primaryKey_? is already set to true in MappedStringIndex. > writePermission_? is set to false by default... > > Derek > > On Mon, Jul 20, 2009 at 7:30 PM, Peter Robinett > <[email protected]>wrote: > > > > > Hi all, > > > I'm using Mapper with MAC addresses as my primary keys: > > class Node extends KeyedMapper[String, Node] { > > def getSingleton = Node > > /* MAC address as primary key */ > > def primaryKeyField = mac > > object mac extends MappedStringIndex(this, 17) { > > override def dbPrimaryKey_? = true > > override def dbDisplay_? = true > > } > > } > > > Unfortunately, if I try to create a new Node and assign a MAC address, > > I get an error saying that I don't have permission: > > scala> Node.create.mac("00:1d:c9:00:04:9f") > > java.lang.Exception: Do not have permissions to set this field > > at net.liftweb.mapper.MappedField$class.set(MappedField.scala:425) > > at net.liftweb.mapper.MappedString.set(MappedString.scala:38) > > at net.liftweb.mapper.MappedString$$anonfun$apply$6.apply > > (MappedString.scala:121) > > at net.liftweb.mapper.MappedString$$anonfun$apply$6.apply > > (MappedString.scala:121) > > at net.liftweb.util.Full.f... > > > How do I go about creating a new Node with the mac address – the > > primary key – of my choosing? > > > Thanks, > > Peter Robinett --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
