tags:

views:

50

answers:

1

I am connected to a oracle database from a scala/lift webapp. I have been able to successfully pull information from the database as I wished but am having one issue.

For each table I want to access I am required to add an ID field so that the app will work with the trait IdPK.

What mapper class or trait can I use to override this? I have been trying to find one but been unable to locate it. Figured people have not always had an ID field on every table they make that is just called ID...

class DN_REC extends LongKeyedMapper[DN_REC] with IdPK { 
 def getSingleton = DN_REC 

 object dn_rec_id extends MappedInt(this){
 }

This is what I am talking about. I would like to use the dn_rec_id as my primary key as it is on the table.

Thanks

+3  A: 

No reason you have to use the IdPK trait. If you check source, youll see its defined as following:

trait IdPK /* extends BaseLongKeyedMapper */ {  
  self: BaseLongKeyedMapper =>  
  def primaryKeyField = id  
  object id extends MappedLongIndex[MapperType](this.asInstanceOf[MapperType])
}  

So basically, it justs creates a long index named id and makes it the primary key. You can easily do this yourself with another name for the id.

Jackson Davis
wow I had tried that but I guess I had messed it up/had some typo or not set it up right in my database cause it works now. Thanks!