[Lift] Re: Mapper and Primary Keys

2009-09-03 Thread Somindra Bhattacharya
Indrajit, Thanks! The problem was in the pom.xml. I fixed that to 1.1-SNAPSHOT and the problem went away. Regards, Som On Sep 2, 8:59 pm, Indrajit Raychaudhuri wrote: > Som, > > 1. Your source code had dbAutoGenerated_?. The actual function is > dbAutogenerated_? (g is in lower case). > Hope

[Lift] Re: Mapper and Primary Keys

2009-09-02 Thread Indrajit Raychaudhuri
Som, 1. Your source code had dbAutoGenerated_?. The actual function is dbAutogenerated_? (g is in lower case). Hope you have the right case for 'g' one :) 2. If your project model (pom.xml) has lift versions set to 1.1- SNAPSHOT, you must be on the master and thus on the latest code. FWIW, dbAut

[Lift] Re: Mapper and Primary Keys

2009-09-02 Thread Somindra Bhattacharya
Hi again, I just wanted to mention that I cannot override dbAutogenerated_?. I get the following error: error: method dbAutogenerated_? overrides nothing override def dbAutogenerated_? = false Looks to me that I am not using the latest framework code. How do I verify this? Thanks, Som On

[Lift] Re: Mapper and Primary Keys

2009-09-02 Thread Somindra Bhattacharya
On Jul 30, 3:36 am, David Pollak wrote: > I had to add a property on MappedField for dbGenerated_? which has to be set > to false. > > Here's the change set and the revised, working (wait for an hour for Hudson > to build the new code) version. > > On Wed, Jul 29, 2009 at 1:26 PM, Peter Robinett

[Lift] Re: Mapper and Primary Keys

2009-08-26 Thread Peter Robinett
Just to follow up on this, using CRUDify's edit page to update a model entry using this primary key causes this exception to be thrown. Is there any way to give Mapper and/or CRUDify a clue that it should update the existing entry, not try to create a new one? Thanks, Peter On Jul 30, 10:47 am,

[Lift] Re: Mapper and Primary Keys

2009-07-30 Thread David Pollak
On Thu, Jul 30, 2009 at 8:16 AM, Peter Robinett wrote: > > Oops, you're right, I just glossed over that. Using that I now get an > error when I try to use a pre-existing primary key: > scala> Cat.create.mac("00:1d:c9:00:04:9f").save > ERROR 23505: The statement was aborted because it would have ca

[Lift] Re: Mapper and Primary Keys

2009-07-30 Thread Peter Robinett
Oops, you're right, I just glossed over that. Using that I now get an error when I try to use a pre-existing primary key: scala> Cat.create.mac("00:1d:c9:00:04:9f").save ERROR 23505: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread David Pollak
Did you look at all the overridden methods on the Cat primary key in the example? You have to override the method that defines the column in the RDBMS to define the column as UNIQUE NOT NULL. On Wed, Jul 29, 2009 at 5:24 PM, Peter Robinett wrote: > > Ahh, here we go: > INFO - CREATE TABLE users

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread Peter Robinett
Ahh, here we go: INFO - CREATE TABLE users (id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY , firstname VARCHAR(32) , lastname VARCHAR(32) , email VARCHAR (48) , locale VARCHAR(16) , timezone VARCHAR(32) , password_pw VARCHAR (48) , password_slt VARCHAR(20) , textarea VARCHAR(2048) , superuser SMA

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread David Pollak
On Wed, Jul 29, 2009 at 4:35 PM, Peter Robinett wrote: > > Thanks, David, I am now able to save the mac address. I am, however, > able to create multiple rows in the database with the same mac > address, suggesting that that the uniqueness of the primary key is not > being enforced. This surprised

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread Peter Robinett
Thanks, David, I am now able to save the mac address. I am, however, able to create multiple rows in the database with the same mac address, suggesting that that the uniqueness of the primary key is not being enforced. This surprised me, as MappedStringIndex extends MappedUniqueId. Does something

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread Peter Robinett
Thanks Derek, but I'm afraid it doesn't. Peter On Jul 29, 1:26 pm, Derek Chen-Becker wrote: > Right. Something like: > > private var myDirty = false > > override def dirty_? = myDirty > > override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?(b) } > > I think that that should work. >

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread Derek Chen-Becker
Right. Something like: private var myDirty = false override def dirty_? = myDirty override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?(b) } I think that that should work. Derek On Wed, Jul 29, 2009 at 1:42 PM, Naftoli Gugenheim wrote: > > Did you try to override def dirty_? and d

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread Peter Robinett
Hi all, My sample code is here: http://github.com/pr1001/lift_1_1_sample/tree/master I hadn't been overriding def dirty_?(b: Boolean) but I see why I need to. With everyone's suggestions, here is how I try to set the MAC address: $ mvn scala:console scala> new bootstrap.liftweb.Boot().boot sca

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread Naftoli Gugenheim
Did you try to override def dirty_? and def dirty_?(b: Boolean), and in the latter set your own private variable and read it in dirty_? (the getter)? - Peter Robinett wrote: Hi Derek, I'm afraid I'm not sure how to do this, since _dirty_? is a private var i

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread Peter Robinett
Hi Derek, I'm afraid I'm not sure how to do this, since _dirty_? is a private var in MappedField: /** * Is the field dirty */ private var _dirty_? = false /** * Is the field dirty (has it been changed since the record was loaded from the database */ def dirty_? = !dbPrimaryKey_? && _dirty_?

[Lift] Re: Mapper and Primary Keys

2009-07-29 Thread David Pollak
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 wrote: > > Sorry to bump this, but does anyone hav

[Lift] Re: Mapper and Primary Keys

2009-07-28 Thread Derek Chen-Becker
Did you override the dirty_? def? Derek On Tue, Jul 28, 2009 at 3:09 PM, Peter Robinett 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 wrote: >

[Lift] Re: Mapper and Primary Keys

2009-07-28 Thread Peter Robinett
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 wrote: > Because it's unique across systems and maps directly to hardware I'm > tracking. But thanks for the equation

[Lift] Re: Mapper and Primary Keys

2009-07-22 Thread Peter Robinett
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 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 > addr

[Lift] Re: Mapper and Primary Keys

2009-07-22 Thread jon
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.Lon

[Lift] Re: Mapper and Primary Keys

2009-07-21 Thread Peter Robinett
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 wrote: > Thanks Derek,

[Lift] Re: Mapper and Primary Keys

2009-07-21 Thread Peter Robinett
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 wrote: > I think that this should work, but I haven't tes

[Lift] Re: Mapper and Primary Keys

2009-07-21 Thread Derek Chen-Becker
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 overr