2015-03-03 42 views
0

我有以下油滑表定義:油滑指數導致的InvocationTargetException拋出

class FooRecords(tag: Tag) extends Table[Foo](tag, Foo.TableName) { 
    def id = column[Int]("ID", O.PrimaryKey) 
    def teamId = column[Int]("TEAM_ID") 
    // ... other columns 
    def * = (id, teamId, /* ... */) <> ((FooRecord.apply _).tupled, FooRecord.unapply) 
    def teamIdIdx = index("team_id_idx", teamId, unique = false) 
} 

// ... 

val fooRecords = TableQuery[FooRecords] 
fooRecords.ddl.createStatements.foreach(x => info(x)) 

如果def teamIdIdx行註釋,它工作正常(但顯然沒有創建索引)。如果它沒有被註釋掉我得到一個InvocationTargetException

Caused by: java.lang.reflect.InvocationTargetException 
     at java.lang.reflect.Method.invokeNative(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:515) 
     at scala.slick.lifted.AbstractTable$$anonfun$indexes$2.apply(AbstractTable.scala:105) 
     at scala.slick.lifted.AbstractTable$$anonfun$indexes$2.apply(AbstractTable.scala:103) 
     at scala.collection.TraversableViewLike$Mapped$$anonfun$foreach$2.apply(TraversableViewLike.scala:169) 
     at scala.collection.TraversableViewLike$Filtered$$anonfun$foreach$4.apply(TraversableViewLike.scala:197) 
     at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) 
     at scala.collection.mutable.IndexedSeqLike$$anon$1.foreach(IndexedSeqLike.scala:52) 
     at scala.collection.TraversableViewLike$Filtered$class.foreach(TraversableViewLike.scala:196) 
     at scala.collection.mutable.IndexedSeqView$$anon$1.foreach(IndexedSeqView.scala:80) 
     at scala.collection.TraversableViewLike$Mapped$class.foreach(TraversableViewLike.scala:168) 
     at scala.collection.SeqViewLike$$anon$3.foreach(SeqViewLike.scala:197) 
     at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:59) 
     at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:104) 
     at scala.collection.ViewMkString$class.thisSeq(TraversableViewLike.scala:22) 
     at scala.collection.SeqViewLike$AbstractTransformed.thisSeq(SeqViewLike.scala:37) 
     at scala.collection.SeqViewLike$$anonfun$sortBy$1.apply(SeqViewLike.scala:266) 
     at scala.collection.SeqViewLike$$anonfun$sortBy$1.apply(SeqViewLike.scala:266) 
     at scala.collection.SeqViewLike$$anon$1.<init>(SeqViewLike.scala:195) 
     at scala.collection.SeqViewLike$class.newForced(SeqViewLike.scala:195) 
     at scala.collection.SeqViewLike$AbstractTransformed.newForced(SeqViewLike.scala:37) 
     at scala.collection.SeqViewLike$class.sortBy(SeqViewLike.scala:266) 
     at scala.collection.SeqViewLike$AbstractTransformed.sortBy(SeqViewLike.scala:37) 
     at scala.slick.lifted.AbstractTable.indexes(AbstractTable.scala:105) 
     at scala.slick.driver.JdbcStatementBuilderComponent$TableDDLBuilder.<init>(JdbcStatementBuilderComponent.scala:597) 
     at scala.slick.driver.SQLiteDriver$TableDDLBuilder.<init>(SQLiteDriver.scala:192) 
     at scala.slick.driver.SQLiteDriver$class.createTableDDLBuilder(SQLiteDriver.scala:133) 
     at scala.slick.driver.SQLiteDriver$.createTableDDLBuilder(SQLiteDriver.scala:260) 
     at scala.slick.driver.SQLiteDriver$.createTableDDLBuilder(SQLiteDriver.scala:260) 
     at scala.slick.driver.JdbcProfile$class.buildTableSchemaDescription(JdbcProfile.scala:39) 
     at scala.slick.driver.SQLiteDriver$.buildTableSchemaDescription(SQLiteDriver.scala:260) 
     at scala.slick.driver.SQLiteDriver$.buildTableSchemaDescription(SQLiteDriver.scala:260) 
     at scala.slick.profile.RelationalProfile$TableQueryExtensionMethods.ddl(RelationalProfile.scala:52) 

我在"com.typesafe.slick" %% "slick" % "2.1.0" Android上19

+1

一個InvocationException總是包含一個原因(e.getCause()),它更加有趣和豐富。 – thoredge 2015-03-03 07:35:25

+0

良好的提示,這是由於Proguard缺少一種'索引'方法 – 2015-03-03 10:29:39

回答

0

這是由於ProGuard的消除index方法。調整build.sbt與:

proguardOptions in Android ++= Seq(
    "-keep class scala.slick.lifted.**", 
    // ... 
} 

幫助。