Hi, I've run into a slight snag with my use of the current approach. I suspect what I'm trying to do is silly. The interaction below is from the lift console and I don't actually use open_! in my code.
--- scala> val b = Book.find(1).open_! l: com......Book = com......Book={id=1,author=1} scala> b.author res3: b.author.type = 1 scala> b.author == 1 res4: Boolean = true --- If for some reason a Book does not have an author (possible in my applications case), b.author would return NULL and comparing b.author == 1 returns Boolean = false This approach works in the actual application, but the compiler generates the following warning. --- warning: comparing values of types Long and object b.author using `==' will always yield false --- In the specific application case I have, I have access to the Author.id and want to check if the book is referring to the author whose ID I have before I do something. I know that I could look up the Author object and do the comparison, but the above seemed to be a useful shortcut. Is there a recommended (succinct) way of accomplishing the above ? I'd like the thank everyone for the patience and help provided so far. Cheers, Achint On Mar 2, 3:26 pm, Mads Hartmann Jensen <mads...@gmail.com> wrote: > On 02/03/2010, at 20.56, Achint Sandhu wrote: > > > > > > > Hi, > > > I'm new to scala (2.7.7) and lift (2.0-M2) and as a learning exercise > > have taken on the translation of an existing rails project into a lift > > application. > > > There are two things I have run into that I'm hoping the more > > experienced members of the list can give me a hand with: > > > 1) Is there a trait in lift that creates and manages an equivalent of > > the createdAt and updatedAt fields that rails provides? I'm thinking > > something along the lines of IdPK, but have been unable to find > > anything. > > > 2) I've been following the wiki article on setting up One-to-Many > > relationships (http://wiki.github.com/dpp/liftweb/how-to-work-with-one- > > to-many-relationships) and am running into a difference in behaviour. > > Following the example, if I look at anAuthor.books, I get back a List > > of Book objects, however when I look at aBook.author, I get back a > > Long with the ID of the Author. I would expect aBook.author to return > > an Author object. I've copied and pasted the example in the wiki, to > > make sure that it wasn't my implementation. > > You should be able to get the object by calling aBook.author.obj - this > should return a Box[Author] so you could get it like this > > aBook.author.obj match { > case Full(a) => a // do something with the autor > case Empty => // if the box is empty, handle it somehow > case _ => // should cover everyhting else, Failure etc > > } > > Hope it helps > > > > > Other than that, so far, it's gone extremely well and I was able to > > get something up and running very quickly which really is a testament > > to the design of the framework. > > > Thanks. > > > Cheers, > > Achint > > > -- > > You received this message because you are subscribed to the Google Groups > > "Lift" group. > > To post to this group, send email to lift...@googlegroups.com. > > To unsubscribe from this group, send email to > > liftweb+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@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.