MetaMapper trying to open Empty Box - best practice?

115 views
Skip to first unread message

opyate

unread,
Nov 18, 2009, 8:37:46 AM11/18/09
to Lift
Hello Lifters,

I'm overriding my model's primary key like so, because the "id" field
is non-autoincrement:

(taken from Derek's suggestion on
http://groups.google.com/group/liftweb/browse_thread/thread/41650fc1eb0098bd/cd93612309878979?lnk=gst&q=primary+key#)

--START--
override def primaryKeyField = id

object id extends MappedLongIndex(this) {
override def dbDisplay_? = true
override def writePermission_? = true
override def dbAutogenerated_? = false
private var myDirty = false
override def dirty_? = myDirty
override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?
(b) }
}
--END--

In my form I also make the id editable as a text field.

However, when I save (click submit on the form), I get a stack trace:

Message: java.lang.NullPointerException: Trying to open an empty Box
net.liftweb.common.EmptyBox.open_$bang(Box.scala:370)
net.liftweb.common.EmptyBox.open_$bang(Box.scala:366)
net.liftweb.mapper.MetaMapper$$anonfun$runAppliers$1$1.apply
(MetaMapper.scala:617)

Line 617 is:
findApplier(indexMap.open_!, rs.getObject(1)) match {

Could someone please shed some light? If I want to override the
primary key, do I need to do extra house-keeping? (e.g. managing
indexMap ?)

I enabled query logging by using the code on
http://groups.google.com/group/liftweb/browse_thread/thread/7d5daf78a7e52275/ff9b6f80e19a999b?lnk=gst&q=addLogFunc#ff9b6f80e19a999b
but I can't see the "insert" SQL code in the logs/console - line 618
probably takes care of that.

Thank you,
Juan

David Pollak

unread,
Nov 18, 2009, 8:48:50 AM11/18/09
to lif...@googlegroups.com
This is a  bug, but in order to debug it, I need a complete, runnable application.  Please create one and put it up on GitHub and then open a ticket at http://github.com/dpp/liftweb/issues


--

You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=.





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

Jim McBeath

unread,
Nov 18, 2009, 9:52:46 AM11/18/09
to lif...@googlegroups.com
Juan,

I ran into this same bug. I have not yet had time to put together a
test app to demonstrate it. That's on my to-do list, but if you get
to it first, that would be great.

Re not seeing the INSERT statement in your log file: the SQL is
only logged after it is executed, and the log info includes how long
it took to execute. Unfortunately, that means that when execution
fails with an exception, there is no easy way to see what the SQL
is that is causing the problem.

--
Jim

On Wed, Nov 18, 2009 at 05:37:46AM -0800, opyate wrote:
> Date: Wed, 18 Nov 2009 05:37:46 -0800 (PST)
> From: opyate <opy...@gmail.com>
> To: Lift <lif...@googlegroups.com>
> Subject: [Lift] MetaMapper trying to open Empty Box - best practice?

opyate

unread,
Nov 18, 2009, 10:04:53 AM11/18/09
to Lift
I'll create the test app momentarily.

Thanks Mr. Pollak - you're the reason I have a San Fran clock on my
dashboard :-)

On Nov 18, 2:52 pm, Jim McBeath <goo...@j.jimmc.org> wrote:
> Juan,
>
> I ran into this same bug.  I have not yet had time to put together a
> test app to demonstrate it.  That's on my to-do list, but if you get
> to it first, that would be great.
>
> Re not seeing the INSERT statement in your log file: the SQL is
> only logged after it is executed, and the log info includes how long
> it took to execute.  Unfortunately, that means that when execution
> fails with an exception, there is no easy way to see what the SQL
> is that is causing the problem.
>
> --
> Jim
>
>
>
> On Wed, Nov 18, 2009 at 05:37:46AM -0800, opyate wrote:
> > Date: Wed, 18 Nov 2009 05:37:46 -0800 (PST)
> > From: opyate <opy...@gmail.com>
> > To: Lift <lif...@googlegroups.com>
> > Subject: [Lift]MetaMappertrying to open Empty Box - best practice?
>
> > Hello Lifters,
>
> > I'm overriding my model's primary key like so, because the "id" field
> > is non-autoincrement:
>
> > (taken from Derek's suggestion on
> >http://groups.google.com/group/liftweb/browse_thread/thread/41650fc1e...)
>
> > --START--
> > override def primaryKeyField = id
>
> >   object id extends MappedLongIndex(this) {
> >     override def dbDisplay_? = true
> >     override def writePermission_? = true
> >     override def dbAutogenerated_? = false
> >     private var myDirty = false
> >     override def dirty_? = myDirty
> >     override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?
> > (b) }
> >   }
> > --END--
>
> > In my form I also make the id editable as a text field.
>
> > However, when I save (click submit on the form), I get a stack trace:
>
> > Message: java.lang.NullPointerException: Trying to open an empty Box
> >    net.liftweb.common.EmptyBox.open_$bang(Box.scala:370)
> >    net.liftweb.common.EmptyBox.open_$bang(Box.scala:366)
> >    net.liftweb.mapper.MetaMapper$$anonfun$runAppliers$1$1.apply
> > (MetaMapper.scala:617)
>
> > Line 617 is:
> > findApplier(indexMap.open_!, rs.getObject(1)) match {
>
> > Could someone please shed some light? If I want to override the
> > primary key, do I need to do extra house-keeping? (e.g. managing
> > indexMap ?)
>
> > I enabled query logging by using the code on
> >http://groups.google.com/group/liftweb/browse_thread/thread/7d5daf78a...

opyate

unread,
Nov 18, 2009, 11:12:04 AM11/18/09
to Lift
Issue created:
http://github.com/dpp/liftweb/issues/#issue/199

The markdown went ballistic, and I don't know how to edit, but I'm
sure the gist is communicated.

Thanks guys!

Ross Mellgren

unread,
Nov 18, 2009, 11:34:07 AM11/18/09
to lif...@googlegroups.com
There's an "edit" and "delete" link near the top (to the right of
"Created nnn minutes ago by opyate", I believe) that you can use.

If you make sure each "code" line has 4 spaces in front of it,
markdown should do the right thing.

-Ross
Reply all
Reply to author
Forward
0 new messages