Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Too many elements for Tuple: 27, allowed: 22

I am new to Slick and using Slick 3.1.1. My table looks like

import java.sql.{Blob, Timestamp}

import slick.collection.heterogeneous.HNil

import slick.driver.MySQLDriver.api._


case class AnomalyC(id: Int, serviceName: String, serviceId: String, timeUpdated: Timestamp, timestamp: Timestamp, anomalyCategoryId: Int,
                    userGroup:Int, riskValue: Float, activityTypeId: Int, destinationHost: String, userName: String, tenantId: Int, information:Blob, timeCreated: Timestamp, userId: Int, anomalyType:Int, anomalyValue:String, measure:Int,
                    userAction:Int, uniqueIdentifier:Int, similarCount:Int, trainingValue:String, state: Int, riskLevel:Int, userRiskLevel:Int,
                    userRiskScore: Float, response:Int)
class Anomaly(tag:Tag) extends Table[AnomalyC](tag, "Anomaly") {
  def id = column[Int]("id")
  def serviceName = column[String]("ServiceName")
  def serviceId = column[Int]("ServiceId")
  def timeUpdated = column[Timestamp]("TimeUpdated")
  def timestamp = column[Timestamp]("Timestamp")
  def anomalyCategoryId = column[Int]("AnomalyCategoryId")
  def userGroup = column[Int]("UserGroup")
  def riskValue = column[Float]("RiskValue")
  def activityTypeId = column[Int]("ActivityTypeId")
  def destinationHost = column[String]("DestinationHost")
  def userName = column[String]("UserName")
  def tenantId = column[Int]("TenantId")
  def information = column[Blob]("Information")
  def timeCreated = column[Timestamp]("TimeCreated")
  def userId = column[Int]("UserId")
  def anomalyType = column[Int]("AnomalyType")
  def anomalyValue = column[String]("AnomalyValue")
  def measure = column[Int]("Measure")
  def userAction = column[Int]("UserAction")
  def uniqueIdentifier = column[String]("UniqueIdentifier")
  def similarCount = column[Int]("SimilarCount")
  def trainingValue = column[String]("TrainingValue")
  def state = column[Int]("State")
  def riskLevel = column[Int]("RiskLevel")
  def userRiskLevel = column[Int]("UserRiskLevel")
  def userRiskScore = column[Float]("UserRiskScore")
  def response = column[Int]("Response")

  def * = (id, serviceName, serviceId, timeUpdated, timestamp, anomalyCategoryId, userGroup,
    riskValue, activityTypeId, destinationHost, userName, tenantId, information, timeCreated, userId, anomalyType, anomalyValue,
    measure, userAction, uniqueIdentifier, similarCount, trainingValue, state, riskLevel, userRiskLevel, userRiskScore, response)

}

When I run this, I get error as

Error:(57, 11) too many elements for tuple: 27, allowed: 22
  def * = (id, serviceName, serviceId, timeUpdated, timestamp, anomalyCategoryId, userGroup,
          ^

What do I do?

like image 253
daydreamer Avatar asked May 12 '16 21:05

daydreamer


2 Answers

You could use HLists. Slick has it's own implementation or for probably better interoperability you could use Shapeless. Here is an article that explains it: http://underscore.io/blog/posts/2015/08/08/slickless.html

Alternatively you can use a case class instead of a tuple.

like image 138
cvogt Avatar answered Sep 23 '22 09:09

cvogt


The following worked for me based on the direction provided by @cvogt.

import java.sql.{Blob, Timestamp}

import slick.collection.heterogeneous.HNil
import slick.collection.heterogeneous.syntax._
import slick.driver.MySQLDriver.api._

class Anomaly(tag:Tag) extends Table[Int :: String :: Int :: Timestamp :: Timestamp :: Int :: Int :: Float :: Int :: String
   :: String :: Int ::Blob :: Timestamp :: Int ::Int ::String ::Int ::Int ::String ::Int ::String :: Int ::Int ::Int ::
  Float :: Int :: HNil ](tag, "Anomaly") {

  def id = column[Int]("id")
  def serviceName = column[String]("ServiceName")
  def serviceId = column[Int]("ServiceId")
  def timeUpdated = column[Timestamp]("TimeUpdated")
  def timestamp = column[Timestamp]("Timestamp")
  def anomalyCategoryId = column[Int]("AnomalyCategoryId")
  def userGroup = column[Int]("UserGroup")
  def riskValue = column[Float]("RiskValue")
  def activityTypeId = column[Int]("ActivityTypeId")
  def destinationHost = column[String]("DestinationHost")
  def userName = column[String]("UserName")
  def tenantId = column[Int]("TenantId")
  def information = column[Blob]("Information")
  def timeCreated = column[Timestamp]("TimeCreated")
  def userId = column[Int]("UserId")
  def anomalyType = column[Int]("AnomalyType")
  def anomalyValue = column[String]("AnomalyValue")
  def measure = column[Int]("Measure")
  def userAction = column[Int]("UserAction")
  def uniqueIdentifier = column[String]("UniqueIdentifier")
  def similarCount = column[Int]("SimilarCount")
  def trainingValue = column[String]("TrainingValue")
  def state = column[Int]("State")
  def riskLevel = column[Int]("RiskLevel")
  def userRiskLevel = column[Int]("UserRiskLevel")
  def userRiskScore = column[Float]("UserRiskScore")
  def response = column[Int]("Response")

   def *  = id :: serviceName :: serviceId :: timeUpdated :: timestamp :: anomalyCategoryId :: userGroup ::
  riskValue :: activityTypeId :: destinationHost :: userName :: tenantId :: information :: timeCreated :: userId :: anomalyType :: anomalyValue ::
  measure :: userAction :: uniqueIdentifier :: similarCount :: trainingValue :: state :: riskLevel :: userRiskLevel :: userRiskScore :: response :: HNil
}

The build runs and test pass, however, I still see IntelliJ complains with the following error

enter image description here

like image 42
daydreamer Avatar answered Sep 23 '22 09:09

daydreamer