Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Best syntax to get primary key as an integer
  2. // projectId and componentId are foreign keys.
  3. case class ProjectComponent(id: Pk[Int], projectId: Int, componentId: Int)
  4.  
  5. object ProjectComponent extends Magic[Event]
  6. {
  7.     def findForProject(project: Project) : List[ProjectComponent]
  8.     {
  9.         val projectId = project.id.get.get
  10.         ProjectComponent.find("projectId=" + projectId).list()    
  11.     }    
  12. }
  13.        
  14. // project.id returns Pk[Int]
  15. // project.id.get returns Option[Int]
  16. // project.id.get.get returns Int    
  17. val projectId = project.id.get.get
  18.        
  19. def apply() = get.get
  20.        
  21. val projectId = project.id.get.get
  22. val projectId = project.id()