Figured it out! Turns out, it was the stored procedure causing all the trouble.
In the procedure I check to see if a ngram exists by doing a dynamic SQL query (since the table name is passed in) that stores a value in
@ngramId, which is a session variable. I store it in
@ngramId and not into
ngramId (a procedure output parameter) because prepared statements can only select into session variables (or so I've been told by an error when I originally created the procedure). Next I set the value of
ngramId and check if
ngramId is null to determine if the ngram exists in the table; if null, the ngram is inserted into the table and
ngramId is set to the last inserted id.
The problem with this is that because
@ngramId is a session variable and because I used the same database connection for all procedures calls, the value of @ngramId persisted between calls. So for example, if I made a call with the ngram "I", and it was found in the database with id 1,
@ngramId now had the value of 1. Next if I tried to insert another ngram that did not exist in the table, the dynamic select statement did not return anything so the value of
@ngramId remained as 1. Since the output parameter
ngramId is populated with the value of
@ngramId and now it was no longer NULL, it bypassed the if statement that inserted the ngram in the database and returned the id of the last ngram found in the table, resulting in the seeming caching of ngram ids.
The solution to this was to add the following line as the very first statement in the procedure:
SET @ngramId = NULL;
Which resets the value of
@ngramId between calls to the procedure over the same session.
- MySQL and JDBC caching (?) issue with procedure call in Scala
- How to stub a method call with an implicit matcher in Mockito and Scala
- How to call Stored Procedures and defined functions in MySQL with Slick 3.0
- Scala and Akka HTTP: Request inside a request & issue with threads
- Strange issue with SBT, println, and scala console application
- Is there a way to call a function defined using `val` in Scala with the whole curly brace block as an argument and not the final result of that block?
- Strange definition and call of a function with curly bracket in Scala (function as parameter of a function)
- Compilation issue in Scala with F-bounded types and existential types
- Compatibility issue with Scala and Spark for compiled jars
- how to create a connection between scala and mysql using jdbc
- Scala type inference with generics and covariance, possible issue in scalac
- rollback transcation in mysql if exception comes in scala. i am using scala with play framework and mysql as backend
- Intellij 15.0.5 issue with SBT and Scala project
- Issue with scala object companion and trait
- How can I call Scala function with class name and function name as strings
- Issue with specialization and higher kinds in scala
- Scala and MySQL JDBC Driver
- mysql connection with scala and sbt
- Issue with dropDuplicates() and except() method in Spark using Scala
- Scala classOf for type parameter: how to call the function and how to restrict with upper type bounds
- Issue with trait and case class inheritance: scala
- How to call a Scala function with a single parameter and write the parameter first
- How to Design and Call Scala API with Futures
- Stripe Payment Library Issue with Scala and Play app
- Issue with @Column annotations in Squeryl with Play Framework and MySQL
- How to override generic method in scala and call it with reflection
- Play 2.3 scala - Slick with MYSQL issue
- scala spark sql with intellij, how to link jdbc jar file and run the scala code
- What's the standard way to work with dates and times in Scala? Should I use Java types or there are native Scala alternatives?
- Debugging Scala code with simple-build-tool (sbt) and IntelliJ
More Query from same tag
- Create custom column mapping for java.time.LocalDate with Slick
- Scala date time convertion using joda datetime
- Java LinkedHashMap to scala Map conversion and recursive conversion
- Scala spray - init on server statup
- sbt release to Maven central fails with no public key error
- Scala and html: download an image (*.jpg, etc) to Hard drive
- JDBC connection to MSSQL server using azure active directory
- How can I alias a covariant generic type parameter
- Postgresql money (or numeric?) type and its corresponding type in Scala (Java)
- Dependency injection with abstract class and object in Play Framework 2.5
- How to implement a JSON that contains a variable from another method in Scala?
- Functional Programming In Scala - reversing lists exercise
- Spark dataframe from Json string with nested key
- Spark: Concatenating lists?
- Scala type mismatch: required _$1 where type _$1 <:
- Play+Scala testing Slick database
- Should my persistence class return Option or rely on exceptions?
- How to parse a csv with matching case class and store the output to treemap[Int, List[List[InputConfig]] object in scala
- type mismatch; found : org.apache.spark.sql.DataFrame required: org.apache.spark.rdd.RDD
- Cannot use lambda expression when filtering or mapping dataset
- Error while writing the content of a file to another in scala
- How to create custom operators with precedence
- Overload private constructor with polymorphic arguments in Scala
- Instanciating POJO with nulls values from Scala Option
- How String class taken high priority than AnyRef while calling with null value?
- Selecting from relations on squeryl
- Connecting MySQL to Scala using slick
- What can I do to my scala code so it will compile faster?
- Scala - how to make generic decoder in circe?
- Regex to match all scala keywords in a file