尝试为具有超过22个参数的案例类创建guice映射

时间:2019-05-14 10:34:26

标签: scala playframework guice slick

我收到以下错误

[error] Make sure that type JdbcTypes is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'SQLServerDriver.class' was compiled against an incompatible version of <none>.JdbcTypesComponent.
[error]   private val orderLineShapedValue = (carryBagRequired,
[error]                                      ^
[error] one error found

我正在尝试分解我的OrderLineDetails case类,以便它仅包含22个参数,因为scala元组尚不支持> 22个参数。但我仍然收到上述错误,无法修复。

有人可以帮我理解这个问题吗?

谢谢!


import java.sql.{Date, Timestamp}
import java.time.ZonedDateTime

import akka.japi.Option.Some
import dal.entity.{LineItemPhysicalInfo, LineItemRemoteInfo, OrderLineDetails}
import slick.lifted.{ProvenShape, Tag}
import com.typesafe.slick.driver.ms.SQLServerDriver.api._
import slick.jdbc
import org.joda.time.DateTime

class OrderLineDetailsTable(tag : Tag) extends Table[OrderLineDetails](tag, "line_details"){
  def carryBagRequired = column[Boolean]("carry_bag_required")(booleanColumnType)
  def commodityCode = column[Int]("commodity_code") (intColumnType)
  def earliestFulfillmentTime = column[ZonedDateTime]("earliest_fulfillment_time")(zonedDateTimeColumnType)//(DateMapper.date2SqlTimestampMapper)
  def remoteBatchId = column[String]("remote_branch_id")(stringColumnType)
  def remoteGroupId = column[String]("remote_group_id")(stringColumnType)
  def remoteGroupCategory = column[String]("remote_group_category")(stringColumnType)
  def optimaGroupId = column[String]("optima_group_id")(stringColumnType)
  def gtinDetails = column[String]("gtin_details")(stringColumnType)
  def itemQuantity = column[Double]("item_quantity")(doubleColumnType)
  def itemWeight = column[Double]("item_weight")(doubleColumnType)
  def itemWeightUOM = column[String]("item_weight_uom")(stringColumnType)
  def lineDueTime = column[ZonedDateTime]("line_due_time")(zonedDateTimeColumnType)//(DateMapper.date2SqlTimestampMapper)
  def lineNumber = column[Int]("line_number")(intColumnType)
  def lineMeta = column[String]("line_meta")(stringColumnType)
  def loadNumber = column[Int]("load_number")(intColumnType)
  def orderId = column[Long]("order_id")(longColumnType)
  def orderStatus = column[String]("order_status")(stringColumnType)
  def osn = column[String]("osn")(stringColumnType)
  def programType = column[String]("program_type")(stringColumnType)
  def primaryGTINDetails = column[String]("primary_gtin_details")(stringColumnType)
  def updatedTime = column[ZonedDateTime]("updated_time")(zonedDateTimeColumnType)//(DateMapper.date2SqlTimestampMapper)
  def createdTime = column[ZonedDateTime]("created_time")(zonedDateTimeColumnType)//(DateMapper.date2SqlTimestampMapper)
  def updateUserId = column[String]("update_user_id")(stringColumnType)
  def storeNumber = column[Int]("store_number")(intColumnType)
  def countryCode = column[String]("country_code")(stringColumnType)
  def divisonNum = column[Int]("divison_num")(intColumnType)

  private type LineItemRemoteInfoTuple = (String,
    String,
    String)

  private type LineItemPhysicalInfoTuple = (Double,
    Double,
    String)

  private type OrderLineDetailsTuple = (Boolean,
    Int,
    ZonedDateTime,
    LineItemRemoteInfoTuple,
    String,
    String,
    LineItemPhysicalInfoTuple,
    ZonedDateTime,
    Int,
    String,
    Int,
    Long,
    String,
    String,
    String,
    String,
    ZonedDateTime,
    ZonedDateTime,
    String,
    Int,
    String,
    Int)

  private val orderLineShapedValue = (carryBagRequired,
    commodityCode,
    earliestFulfillmentTime,
    (remoteBatchId, remoteGroupId, remoteGroupCategory),
    optimaGroupId,
    gtinDetails,
    (itemQuantity, itemWeight, itemWeightUOM),
    lineDueTime,
    lineNumber,
    lineMeta,
    loadNumber,
    orderId,
    orderStatus,
    osn,
    programType,
    primaryGTINDetails,
    updatedTime,
    createdTime,
    updateUserId,
    storeNumber,
    countryCode,
    divisonNum
  ).shaped//shape[ProvenShape[OrderLineDetailsTuple]]

  private val toOrderLineDetails : (OrderLineDetailsTuple => OrderLineDetails) = { orderLineDetailsTuple =>
    OrderLineDetails (
      orderLineDetailsTuple._1,
      orderLineDetailsTuple._2,
      orderLineDetailsTuple._3,
      LineItemRemoteInfo.tupled.apply(orderLineDetailsTuple._4),
      orderLineDetailsTuple._5,
      orderLineDetailsTuple._6,
      LineItemPhysicalInfo.tupled.apply(orderLineDetailsTuple._7),
      orderLineDetailsTuple._8,
      orderLineDetailsTuple._9,
      orderLineDetailsTuple._10,
      orderLineDetailsTuple._11,
      orderLineDetailsTuple._12,
      orderLineDetailsTuple._13,
      orderLineDetailsTuple._14,
      orderLineDetailsTuple._15,
      orderLineDetailsTuple._16,
      orderLineDetailsTuple._17,
      orderLineDetailsTuple._18,
      orderLineDetailsTuple._19,
      orderLineDetailsTuple._20,
      orderLineDetailsTuple._21,
      orderLineDetailsTuple._22
    )
  }

  private val toOrderLineDetailsTuple : (OrderLineDetails => Option[OrderLineDetailsTuple]) = { orderLineDetails =>
    Some (
      orderLineDetails.carryBagRequired,
      orderLineDetails.commodityCode,
      orderLineDetails.earliestFulfillmentTime,
      LineItemRemoteInfo.unapply(orderLineDetails.remoteInfo).get,
      orderLineDetails.optimaGroupId,
      orderLineDetails.gtinDetails,
      LineItemPhysicalInfo.unapply(orderLineDetails.physicalInfo).get,
      orderLineDetails.lineDueTime,
      orderLineDetails.lineNumber,
      orderLineDetails.lineMeta,
      orderLineDetails.loadNumber,
      orderLineDetails.orderId,
      orderLineDetails.orderStatus,
      orderLineDetails.osn,
      orderLineDetails.programType,
      orderLineDetails.primaryGTINDetails,
      orderLineDetails.updatedTime,
      orderLineDetails.createdTime,
      orderLineDetails.updateUserId,
      orderLineDetails.storeNumber,
      orderLineDetails.countryCode,
      orderLineDetails.divisonNum
    )
  }

  def * = orderLineShapedValue <> (toOrderLineDetails, toOrderLineDetailsTuple)

  /*implicit def jodaTimeMapping: BaseColumnType[DateTime] = MappedColumnType.base[DateTime, Date](
    dateTime => new Date(dateTime.getMillis),
    date => new DateTime(date.getTime)
  )*/

  /*object DateMapper {
    implicit val date2SqlTimestampMapper = MappedColumnType.base[DateTime, java.sql.Timestamp](
      { dateTime: DateTime => new java.sql.Timestamp(dateTime.getMillis) },
      { sqlTimestamp => new DateTime(sqlTimestamp.getTime) })
  }
*/
}
                            /*carryBagRequired : Boolean,
                             commodityCode : Int,
                             earliestFulfillmentTime : DateTime,
                             remoteInfo : LineItemRemoteInfo,
                             optimaGroupId : String,
                             gtinDetails : String,
                             physicalInfo: LineItemPhysicalInfo,
                             lineDueTime : DateTime,
                             lineNumber : Int,
                             lineMeta : String,
                             loadNumber : Int,
                             orderId : Long,
                             orderStatus : String,
                             osn : String,
                             programType : String,
                             primaryGTINDetails : String,
                             updatedTime : DateTime,
                             createdTime : DateTime,
                             updateUserId : String,
                             storeNumber : Int,
                             countryCode : String,
                             divisonNum : Int*/```

0 个答案:

没有答案