I am a Software/DevOps engineer who spent 10 years experimenting and learning by myself. I believe that IT can help build a better world if we collaborate. It is now time to share everything with you.
I wrote a code based on what you wrote, and have difficulties to persist an entity in the database.
javax.persistence.PersistenceException: No Persistence provider for EntityManager named PersistenceProviderMysql
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:85)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at KrakenConnector.saveLastPrice(KrakenConnector.kt:42)
at KrakenConnector.getAndSaveLastPrice(KrakenConnector.kt:17)
I added a persistence.xml file at the following path: src/main/resources/META-INF
fun saveLastPrice(ohlcs: KrakenOHLCs) {
val krakenOHLCsPersistable = KrakenOHLCsPersistable(ohlcs.ohlCs, 1)
val emFactory: EntityManagerFactory = Persistence.createEntityManagerFactory("PersistenceProviderMysql")
val entityManager = emFactory.createEntityManager()
entityManager.transaction.begin()
entityManager.persist(krakenOHLCsPersistable)
entityManager.transaction.commit()
entityManager.close()
emFactory.close()
}
I added "javax.persistence-api" version 2.2 as dependency in my pom.xml and also enabled the JPA support as described here kotlinlang.org/docs/reference/comp....
I am pretty sure the persistence.xml file is not detected because the error is the same when I delete it.
Could you provide the full working code of your example so I can try to reproduce it ?
Thanks in advance for your help,
Tony
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hello,
Thanks for your article.
I wrote a code based on what you wrote, and have difficulties to persist an entity in the database.
I added a persistence.xml file at the following path: src/main/resources/META-INF
And the code to persist my entity is:
I added "javax.persistence-api" version 2.2 as dependency in my pom.xml and also enabled the JPA support as described here kotlinlang.org/docs/reference/comp....
I am pretty sure the persistence.xml file is not detected because the error is the same when I delete it.
Could you provide the full working code of your example so I can try to reproduce it ?
Thanks in advance for your help,
Tony