[Lift] Mapper with id=-1

2009-08-11 Thread Steffen Weißmann

Hi,

i am using two Mapper classes, both extend LongKeyedMapper[..] with
IdPK. After saving (returns true for both) one class always has id=-1,
the id of the other class counts up as expected. The id is however
correct when i list the table from another snippet. Any hints?

Thanks, Steffen.

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Mapper with id=-1

2009-08-11 Thread Steffen Weißmann

Sorry, it was a beginning scala problem: Instead of

val prod = Product.create i had
def prod = Product.create...

then prod.save returned true and prod.id=-1...

Also sorry for posting this twice, but for some reason it took several
hours until the mails showed up on the list, I didn't expect that...

BTW: I have bought your Lift book (the paper version...), and I am a
little disappointed that it has neither an appendix nor an index. What
was the reason for that?


Cheers, Steffen.

On Tue, Aug 11, 2009 at 8:34 PM, Derek Chen-Beckerdchenbec...@gmail.com wrote:
 Is it always the same one that gets a correct ID, and if you comment out
 that save does the other one get a correct ID? I'm just wondering if there's
 something sequential related to retrieving the generated IDs.

 Derek

 On Tue, Aug 11, 2009 at 6:25 AM, Steffen Weißmann
 steffen.weissm...@googlemail.com wrote:

 Hi,

 i am using two Mapper classes, both extend LongKeyedMapper[..] with
 IdPK. After saving (returns true for both) one class always has id=-1,
 the id of the other class counts up as expected. The id is however
 correct when i list the table from another snippet. Any hints?

 Thanks, Steffen.




 




-- 
Steffen Weissmann

Technische Universitaet Berlin - Math. Department - MA 3-2

Str. des 17. Juni 136
10623 Berlin - Germany

Phone: +49 30 314-29278
Mail: weissm...@math.tu-berlin.de
Web: www.math.tu-berlin.de/~weissman

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Mapper with id=-1

2009-08-11 Thread Steffen Weißmann

I was aware of master.pdf before I ordered the book. Somehow I had
expected that the publisher would do some value-adding for the print
version, like formatting and indexing.  When I tried to follow a See
appendix... hint in the book for the first time I thought amazon had
sent me a misprint version... Another thing that I really miss is a
page header telling the current chapter. Just in case you publish a
second edition ;-)

Nonetheless thanks for writing the book!

Steffen.

 We're also disappointed that the book had neither an index or the
 appendices. Their omission was due to some issues with the way that APress
 handles FirstPress books. The index was definitely not possible for them,
 and the removal of the appendices was done so that the book would be printed
 in time (their printing workflow supposedly didn't allow for  X chapters
 and would have had to been rewritten). The appendices are available in PDF
 here:

 http://www.apress.com/book/downloadfile/4390

 If you want a full PDF with index and appendices, you can check out the
 open-source version of the book here:

 http://groups.google.com/group/the-lift-book

 The master.pdf under Files is the most up-to-date version, and as I have
 time I update it with feedback. The two versions aren't 100% identical but
 they are very similar.

 Derek

 On Tue, Aug 11, 2009 at 1:01 PM, Steffen Weißmann
 steffen.weissm...@googlemail.com wrote:

 Sorry, it was a beginning scala problem: Instead of

 val prod = Product.create i had
 def prod = Product.create...

 then prod.save returned true and prod.id=-1...

 Also sorry for posting this twice, but for some reason it took several
 hours until the mails showed up on the list, I didn't expect that...

 BTW: I have bought your Lift book (the paper version...), and I am a
 little disappointed that it has neither an appendix nor an index. What
 was the reason for that?


 Cheers, Steffen.

 On Tue, Aug 11, 2009 at 8:34 PM, Derek Chen-Beckerdchenbec...@gmail.com
 wrote:
  Is it always the same one that gets a correct ID, and if you comment out
  that save does the other one get a correct ID? I'm just wondering if
  there's
  something sequential related to retrieving the generated IDs.
 
  Derek
 
  On Tue, Aug 11, 2009 at 6:25 AM, Steffen Weißmann
  steffen.weissm...@googlemail.com wrote:
 
  Hi,
 
  i am using two Mapper classes, both extend LongKeyedMapper[..] with
  IdPK. After saving (returns true for both) one class always has id=-1,
  the id of the other class counts up as expected. The id is however
  correct when i list the table from another snippet. Any hints?
 
  Thanks, Steffen.
 
 
 
 
  
 



 --
 Steffen Weissmann

 Technische Universitaet Berlin - Math. Department - MA 3-2

 Str. des 17. Juni 136
 10623 Berlin - Germany

 Phone: +49 30 314-29278
 Mail: weissm...@math.tu-berlin.de
 Web: www.math.tu-berlin.de/~weissman




 


--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: how do you initialise a MappedLongForeignKey object?

2009-08-11 Thread Steffen Weißmann

I think the problem is the new Address. You need
Address.create.save. My code is:

def addAddress(form: NodeSeq) = {
val user = User.currentUser.open_!
val addr = user.address.obj.openOr {
val newAdr = Address.create
newAdr.save
user.address(newAdr).save
println(Creating new Address for user 
+user.firstName+ +user.lastName)
newAdr
}
def doBind(form: NodeSeq): NodeSeq =
table{bind(form, form,
table - 
addr.toForm(Full(S.?(address.submit)), doBind, addr
= addr.save)
)}/table
doBind(form)
}

Steffen.

On Tue, Aug 11, 2009 at 10:48 PM, Naftoli Gugenheimnaftoli...@gmail.com wrote:

 Try mixing in LongMappedForeignMapper to address, or calling 
 address.primeObj(addressObj).
 What doesn't work the way you tried?

 -
 georgegeo...@mattandgeorge.com wrote:


 I have extended MegaProtoUser in order to add a related Address object
 which is a MappedLongForeignKey.

 The idea being simply that there is a 1 to 1 relationship between a
 User and their Address.

 When a new User object is instantiated (but not yet persisted), I want
 to be able to get the related address object like this:

 user.address.obj

 But the returned Box is always empty, I guess because nothing has been
 saved yet.

 I need to somehow initialise the address if it is Empty otherwise
 return the current Address.

 I thought something like this would work, but it doesn't:

 user.address.obj.openOr(user.address(new Address).address.obj.open_!)

 Anyone know how to do this properly?


 




-- 
Steffen Weissmann

Technische Universitaet Berlin - Math. Department - MA 3-2

Str. des 17. Juni 136
10623 Berlin - Germany

Phone: +49 30 314-29278
Mail: weissm...@math.tu-berlin.de
Web: www.math.tu-berlin.de/~weissman

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Eclipse setup

2009-08-07 Thread Steffen Weißmann

 See if the following configuration helps you as it solved most of my
 problems.

        
 http://blog.spiralarm.com/richard/2009/07/using-existing-scala-maven-project-in.html

Thanks, works much better now. I create the eclipse project via mvn
eclipse:eclipse, import it, remove all src-folders and add only
src/main/scala back as a source folder, with default output path
target/classes. And I have removed the maven plugin completely, I
think that helped a lot...

Now I can really use eclipse again, thanks!

Cheers, Steffen.



 Cheers
 Jono


 On 07/08/2009, at 6:44 AM, Steffen Weißmann wrote:


 You have two output folders: the Scala IDE = 2.7.5.final only
 supports one. Use a single default output folder.
 That helped somehow, at least in the Boot.scala file it was pretty
 much ok. But the other files were no better. For instance, clicking on
 MetaProtoUser still opens Object.java source...

 You also have source directories nested below the top level of your
 project. Although I've seen reports that this works from various
 people, there's code in 2.7.5.final and earlier which makes this
 unlikely. If switching to a single output folder doesn't solve your
 problems try also moving your source directories to the top level.
 I tried to move the scala src folder src/main/scala to the project
 root, but that didn't improve things.

 I really would like to use eclipse, but right now i am using idea
 (even though I completely agree with David Pollaks blog posts...)
 since it usually understands the scala source code and it usually
 displays the lift code (and also other code) properly.

 I guess several people are developing lift projects with eclipse, so I
 hope there is a chance to get it working. Is there any configuration
 (Eclipse version+plugin versions+project setup) that is known to work?

 Both of these issues are fixed on trunk (but don't go there unless
 you're using the Lift 2.8.0 branch).
 Unfortunately it didn't help to avoid these two issues...

 Let me know how you get on ...
 Well, I switched to idea for now, and i don't like it. Would it make
 sense to use the trunk version?

 Cheers, Steffen.


 Cheers,


 Miles

 --
 Miles Sabin
 tel: +44 (0)7813 944 528
 skype:  milessabin
 http://www.chuusai.com/
 http://twitter.com/milessabin






 --
 Steffen Weissmann

 Technische Universitaet Berlin - Math. Department - MA 3-2

 Str. des 17. Juni 136
 10623 Berlin - Germany

 Phone: +49 30 314-29278
 Mail: weissm...@math.tu-berlin.de
 Web: www.math.tu-berlin.de/~weissman

 


 




-- 
Steffen Weissmann

Technische Universitaet Berlin - Math. Department - MA 3-2

Str. des 17. Juni 136
10623 Berlin - Germany

Phone: +49 30 314-29278
Mail: weissm...@math.tu-berlin.de
Web: www.math.tu-berlin.de/~weissman

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Eclipse setup

2009-08-06 Thread Steffen Weißmann

 You have two output folders: the Scala IDE = 2.7.5.final only
 supports one. Use a single default output folder.
That helped somehow, at least in the Boot.scala file it was pretty
much ok. But the other files were no better. For instance, clicking on
MetaProtoUser still opens Object.java source...

 You also have source directories nested below the top level of your
 project. Although I've seen reports that this works from various
 people, there's code in 2.7.5.final and earlier which makes this
 unlikely. If switching to a single output folder doesn't solve your
 problems try also moving your source directories to the top level.
I tried to move the scala src folder src/main/scala to the project
root, but that didn't improve things.

I really would like to use eclipse, but right now i am using idea
(even though I completely agree with David Pollaks blog posts...)
since it usually understands the scala source code and it usually
displays the lift code (and also other code) properly.

I guess several people are developing lift projects with eclipse, so I
hope there is a chance to get it working. Is there any configuration
(Eclipse version+plugin versions+project setup) that is known to work?

 Both of these issues are fixed on trunk (but don't go there unless
 you're using the Lift 2.8.0 branch).
Unfortunately it didn't help to avoid these two issues...

 Let me know how you get on ...
Well, I switched to idea for now, and i don't like it. Would it make
sense to use the trunk version?

Cheers, Steffen.


 Cheers,


 Miles

 --
 Miles Sabin
 tel: +44 (0)7813 944 528
 skype:  milessabin
 http://www.chuusai.com/
 http://twitter.com/milessabin

 




-- 
Steffen Weissmann

Technische Universitaet Berlin - Math. Department - MA 3-2

Str. des 17. Juni 136
10623 Berlin - Germany

Phone: +49 30 314-29278
Mail: weissm...@math.tu-berlin.de
Web: www.math.tu-berlin.de/~weissman

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Eclipse setup

2009-08-05 Thread Steffen Weißmann
 Can you show me the contents of your .project and .classpath files.

Both files attached. Thanks for looking into it...

On Wed, Aug 5, 2009 at 11:34 PM, Miles Sabinmi...@milessabin.com wrote:

 On Wed, Aug 5, 2009 at 10:21 PM,
 steffen.weissmannsteffen.weissm...@googlemail.com wrote:
 I have trouble with getting started with lift in eclipse. In my
 project, created from lift-archetype-basic 1.1-SNAPSHOT, i have all
 the lift jars with attached sources (all in the maven repository)
 under Referenced Libraries. I can also browse the source code by
 double-clicking on the classes there, but i have no code completion
 for many of these classes. Sometimes when Ctrl-clicking on a Scala
 type it opens Object.java source... What I am using is Eclipse Galileo
 with Scala plugin 2.7.5.

 This sounds like Maven breakage yet again.

 Can you show me the contents of your .project and .classpath files.

 Cheers,


 Miles

 --
 Miles Sabin
 tel: +44 (0)7813 944 528
 skype:  milessabin
 http://www.chuusai.com/
 http://twitter.com/milessabin

 




-- 
Steffen Weissmann

Technische Universitaet Berlin - Math. Department - MA 3-2

Str. des 17. Juni 136
10623 Berlin - Germany

Phone: +49 30 314-29278
Mail: weissm...@math.tu-berlin.de
Web: www.math.tu-berlin.de/~weissman

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



.classpath
Description: Binary data


.project
Description: Binary data