Hi,

What is the best way to copy values from one mapped object to another
(of the same type). The code below seems to work but I was wondering if
there's a better way?

  def insertOrUpdate(v:Vehicle) = Vehicle.find(By(vin, v.vin.is)) match {
      case Full(existing) => {
        existing.getSingleton.mappedFields.foreach (f => v.fieldByName(f.name) 
match {
          case Full(field) if (!field.dbPrimaryKey_?) =>  
            f.asInstanceOf[MappedField[Any, 
Vehicle]].setFromAny(field.asInstanceOf[MappedField[Any, Vehicle]].is);
          case _ => 
          }
        )
        existing.save
        existing
        }
      case _ => v.save; v

/Jeppe

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

Reply via email to