JPA persistence.xml With SBT Project

277 views Asked by At

I placed the persistence.xml file in history/src/main/resources/META-INF/ yet I am still getting an error.

Where should I be putting the XML file, and what should I change with SBT?

SBT:

lazy val history = (project in file("history"))
  .settings(
    libraryDependencies += "com.impetus.kundera.client" % "kundera-cassandra" % "2.17"
  )

Some Scala Code: (Java Conversion is Straightforward)

object Test {
  def main(args: Array[String]) {

    new HistoryCore()

  }
}

class HistoryCore {

  val emf: EntityManagerFactory = Persistence.createEntityManagerFactory("cassandra_pu")

  val em: EntityManager = emf.createEntityManager()
  em.persist(TradeData(DateTime.now(), 1.618))
  em.close()
  emf.close()

  // @BeanProperty dynamically adds a getter and a setter for the given variable. This keeps the code clean and the JPA implementation working
  @Entity
  @Table(name = "users", schema = "KunderaExamples@cassandra_pu")
  case class TradeData(@Id
                       @BeanProperty
                       var time: DateTime,
                       @Column(name = "price")
                       @BeanProperty
                       var price: Double)
}

Error:

20:45:47.537 [main] INFO  c.i.k.p.EntityManagerFactoryImpl - Loading Core
20:45:47.770 [main] INFO  c.impetus.kundera.loader.CoreLoader - Loading Kundera Core Metdata ... 
20:45:47.775 [main] INFO  c.i.k.p.EntityManagerFactoryImpl - Loading Persistence Unit MetaData For Persistence Unit(s) cassandra_pu.
20:45:47.789 [main] INFO  c.i.k.c.PersistenceUnitConfiguration - Loading Metadata from persistence.xml ...
20:45:47.794 [main] ERROR c.i.k.c.PersistenceUnitConfiguration - Could not find any META-INF/persistence.xml file in the classpath

Project Structure:

enter image description here

0

There are 0 answers