私は次のクラスを持っています:
case class Product( title : String, description: String, contract: Contract)
case class Contract(contractType: ContractType, price: Int )
case class ContractType(description: String)
およびこれらの DTO:
case class ProductDto(id: Long, title: String, description: String, contractType: ContractTypeDto, price: Int)
case class ContractTypeDto(id: Long, description: String)
製品のリストを返すメソッドを作成する必要がありますが、データは次のように DTO に入力されています。
def list = Db.query[Product].fetch().toList.map(x => ProductDto(x.id, x.title,
x.description, ContractTypeDto(x.contract.contractType.id,
x.contract.contractType.description), x.contract.price))
問題は、 x.contract.contractType.id にアクセスできないことですが、SORM ではx.id
(最初のレベルで) アクセスできます。それを行う方法はありますか??
ありがとう