Hi Tim,

On Mon, Sep 8, 2008 at 12:29 PM, Tim Perrett wrote:
>
> Just been doing some more debugging on this - it appears that the
> correct values are being passed through and are assigned to an entity
> instance, but they blow up when trying to do the em.merge(author)
> call.
>
> The stack trace I get is:

You didn't post the full stack trace (or at least, it didn't show up
in gmail), but there are only two places I can see merge being called:

(Authors)
  def add (xhtml : NodeSeq) : NodeSeq = {
    def doAdd () = {
      if (author.name.length == 0) {
        error("emptyAuthor", "The author's name cannot be blank")
      } else {
        Model.merge(author)
        redirectTo("list.html")
      }
    }

and (Books) ....

  def add (xhtml : NodeSeq) : NodeSeq = {
    def doAdd () = {
      Model.merge(book)
      redirectTo("list.html")
    }


The above looks slightly fishy, but I'm afraid I don't have time right
now to try the project to check.

If you want to add something, shouldn't you be calling persist rather
than merge?
I'd expect to see merge being used in a method called doUpdate() or whatever...
... or can you really get away with calling merge when something's not
in the DB yet?

Just a thought.

Regards
Martin

>
> ### AUTHOR
> [EMAIL PROTECTED]
> ### AUTHOR ID
> 0
> ### AUTHOR NAME
> sdfsdssdfs
> DEBUG - opened session at timestamp: 12208732519
> DEBUG - begin
> DEBUG - opening JDBC connection
> DEBUG - total checked-out connections: 0
> DEBUG - using pooled JDBC connection, pool size: 0
> DEBUG - current autocommit status: true
> DEBUG - disabling autocommit
> DEBUG - after transaction begin
> DEBUG - id unsaved-value: 0
> DEBUG - transient instance of: com.foo.jpaweb.model.Author
> DEBUG - merging transient instance
> DEBUG - saving [com.foo.jpaweb.model.Author#<null>]
> DEBUG - executing insertions
> DEBUG - Wrapped collection in role: com.foo.jpaweb.model.Author.books
> DEBUG - executing identity-insert immediately
> DEBUG - Inserting entity: com.foo.jpaweb.model.Author (native id)
> DEBUG - about to open PreparedStatement (open PreparedStatements: 0,
> globally: 0)
> DEBUG - insert into authors (name, id) values (?, ?)
> Hibernate: insert into authors (name, id) values (?, ?)
> DEBUG - preparing statement
> DEBUG - Dehydrating entity: [com.foo.jpaweb.model.Author#<null>]
> DEBUG - binding 'sdfsdssdfs' to parameter: 1
> DEBUG - about to close PreparedStatement (open PreparedStatements: 1,
> globally: 1)
> DEBUG - closing statement
> DEBUG - could not insert: [com.foo.jpaweb.model.Author] [insert into
> authors (name, id) values (?, ?)]
> java.sql.SQLException: Parameter #2 has not been set.
>        at
> net.sourceforge.jtds.jdbc.ConnectionJDBC2.prepareSQL(ConnectionJDBC2.java:
> 613)

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to