Peter,

Please fork http://github.com/dpp/lift_1_1_sample/tree/master and create an
app that's failing in your GitHub repo.  Once we have code to work with, we
can solve the problem.

Thanks,

David

On Tue, Jul 28, 2009 at 2:09 PM, Peter Robinett <[email protected]>wrote:

>
> Sorry to bump this, but does anyone have any idea why my mac column is
> not being saved to the database, despite the save method returning
> true?
>
> On Jul 22, 9:19 am, Peter Robinett <[email protected]> wrote:
> > Because it's unique across systems and maps directly to hardware I'm
> > tracking. But thanks for the equations!
> >
> > Peter
> >
> > On Jul 21, 7:20 pm, jon <[email protected]> wrote:
> >
> > > This doesn't address your question, so I'll apologize in advance, but
> > > why do you want to use a mac address as a primary key?   Also, a mac
> > > address represents six bytes, why not pack into a long?  This probably
> > > isn't the most efficient or prettiest way:
> >
> > >   def macToLong(mac: String) = java.lang.Long.parseLong(mac.replace
> > > (":",""),16)
> >
> > >   def longToMac(mac: Long) = (0 to 5).reverse.map( i => (mac & ((0xff)
> > > << (i * 8).asInstanceOf[Long])) >> (i * 8)).
> > >     map( l => String.format("%02x",l.asInstanceOf[Object])).mkString
> > > (":")
> >
> > >   println( longToMac(macToLong("00:1d:c9:00:04:9f")))
> >
> > > On Jul 21, 4:19 pm, Peter Robinett <[email protected]> wrote:
> >
> > > > I should add that I believe this is because the field isn't being
> > > > marked as dirty and so isn't saved. This is in MappedField:
> > > > def dirty_? = !dbPrimaryKey_? && _dirty_?
> >
> > > > How would I overload it in my object mac definition?
> >
> > > > Thanks,
> > > > Peter
> >
> > > > On Jul 21, 12:30 pm, Peter Robinett <[email protected]> wrote:
> >
> > > > > 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
> >
>


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

Reply via email to