Ich verwende Slick 3.1.0 und muss das Feld vom Typ java.time.LocalDate beibehalten.Slick 3 java.time.LocalDate Mapping
Ich habe die Modellklasse:
case class Position(companyName: String, title: String, startDate: Option[LocalDate], endDate: Option[LocalDate], positionId: Option[Int] = None)
Und die folgende Abbildung:
private[PositionTable] class PositionTable(tag: Tag) extends Table[Position](tag, "POSITIONS") {
val positionId = column[Int]("POSITION_ID", O.PrimaryKey, O.AutoInc)
val companyName = column[String]("COMPANY_NAME")
val title = column[String]("TITLE")
val startDate = column[Date]("START_DATE")
val endDate = column[Date]("END_DATE")
def * = (companyName, title, startDate, endDate, positionId.?) <>(Position.tupled, Position.unapply)
}
Wie kann ich Karte und startdate endDate Felder mit DATE-Typ in der Datenbank dargestellt werden?
Stacktrace für Nullpointer in Spalte Mapper:
java.lang.NullPointerException
at com.tiedin.repo.PositionTable$class.$init$(PositionRepository.scala:54)
at repo.PositionRepositoryTest.<init>(PositionRepositoryTest.scala:13)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at java.lang.Class.newInstance(Class.java:442)
at org.scalatest.tools.Runner$.genSuiteConfig(Runner.scala:1422)
at org.scalatest.tools.Runner$$anonfun$31.apply(Runner.scala:1236)
at org.scalatest.tools.Runner$$anonfun$31.apply(Runner.scala:1235)
at scala.collection.immutable.List.map(List.scala:273)
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1235)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1011)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:1010)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1500)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1010)
at org.scalatest.tools.Runner$.run(Runner.scala:850)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:138)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Der folgende Code erzeugt die Nullpointer, wenn ich es in der Zeile, in der impliziten val localDateToDate zugeordnet Wert zu testen versuchen. –
@IlyaZinkovich Haben Sie einen glatten Fahrer an Ort und Stelle? Fügen Sie Ihrer Frage einen Stack-Trace hinzu. – Roman
Die Frage wurde aktualisiert, StackTrace wurde hinzugefügt –