ScalaReflectException in createCompositeArrayJdbcType
Hi, I'm getting a very weird and very long ScalaReflectException in runtime when trying to insert data into DB.
Here's the part that fails:
implicit lazy val cordialFeedVariantArrayTypeMapper: DriverJdbcType[List[CordialFeedVariant]] =
createCompositeArrayJdbcType[CordialFeedVariant]("CordialFeedVariant").to(_.toList)
The exact point of failure is PgCompositeSupport.scala:71 (typeOf), the message is that class CordialFeedVariant is not found.
Please let me know you need any additional info. Thanks.
I've found a workaround which is to manually create the AdvancedArrayJdbcType constructing and parsing strings manually.
Here's related codes for createCompositeArrayJdbcType,
def createCompositeArrayJdbcType[T <: Struct](sqlTypeName: String, cl: ClassLoader = getClass.getClassLoader)(implicit ev: u.TypeTag[T], tag: ClassTag[T]) = {
val util = new PgCompositeSupportUtils(cl, emptyMembersAsNull)
new AdvancedArrayJdbcType[T](sqlTypeName, util.mkCompositeSeqFromString[T], util.mkStringFromCompositeSeq[T])
}
Maybe cordialFeedVariantArrayTypeMapper and CordialFeedVariant were loaded by different classloader.
Try createCompositeArrayJdbcType[CordialFeedVariant]("CordialFeedVariant", classOf[CordialFeedVariant].getClassLoader)?
Won't compile:
[error] /home/yan/git/upstart/data-feeds-svc/data-feeds-impl/src/main/scala/com/upstartcommerce/datafeeds/impl/repo/DataFeedsTables.scala:270:100: polymorphic expression cannot be instantiated to expected type;
[error] found : [SEQ[T]]SEQ[T] => Seq[T]
[error] required: List[com.upstartcommerce.datafeeds.impl.repo.CordialFeedVariant] => Seq[com.upstartcommerce.datafeeds.impl.repo.CordialFeedVariant]
[error] Error occurred in an application involving default arguments.
[error] createCompositeArrayJdbcType("CordialFeedVariant", classOf[CordialFeedVariant].getClassLoader).to(_.toList)
[error] ^
[info] SEQ[T] => Seq[T] <: List[com.upstartcommerce.datafeeds.impl.repo.CordialFeedVariant] => Seq[com.upstartcommerce.datafeeds.impl.repo.CordialFeedVariant]?
[info] false