https://kotlinlang.org logo
#exposed
Title
# exposed
b

Bastien Leveque

03/03/2024, 7:42 PM
Hello, I have a small problem with Exposed and I can't understand where it comes from or how to solve it. https://github.com/OcelusPRO/EconomyBot
Copy code
2024-03-03 18:04:50 java.lang.reflect.InvocationTargetException
2024-03-03 18:04:50   at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2024-03-03 18:04:50   at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
2024-03-03 18:04:50   at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2024-03-03 18:04:50   at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
2024-03-03 18:04:50   at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
2024-03-03 18:04:50   at kotlin.reflect.jvm.internal.calls.CallerImpl$Constructor.call(CallerImpl.kt:41)
2024-03-03 18:04:50   at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:107)
2024-03-03 18:04:50   at org.jetbrains.exposed.dao.EntityClass$entityCtor$1.invoke(EntityClass.kt:32)
2024-03-03 18:04:50   at org.jetbrains.exposed.dao.EntityClass$entityCtor$1.invoke(EntityClass.kt:32)
2024-03-03 18:04:50   at org.jetbrains.exposed.dao.EntityClass.createInstance(EntityClass.kt:229)
2024-03-03 18:04:50   at org.jetbrains.exposed.dao.EntityClass.new(EntityClass.kt:264)
2024-03-03 18:04:50   at org.jetbrains.exposed.dao.EntityClass.new(EntityClass.kt:247)
2024-03-03 18:04:50   at fr.ftnl.economy.database.models.BankAccount2$Companion.create$lambda$1(BankAccountTable2.kt:29)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction$run(ThreadLocalTransactionManager.kt:215)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.access$inTopLevelTransaction$run(ThreadLocalTransactionManager.kt:1)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$1.invoke(ThreadLocalTransactionManager.kt:241)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:249)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:240)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$transaction$1.invoke(ThreadLocalTransactionManager.kt:190)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:249)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:160)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:146)
2024-03-03 18:04:50   at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction$default(ThreadLocalTransactionManager.kt:145)
2024-03-03 18:04:50   at fr.ftnl.economy.database.models.BankAccount2$Companion.create(BankAccountTable2.kt:28)
2024-03-03 18:04:50   at fr.ftnl.economy.bot.commands.modules.Balance.action(Balance.kt:26)
2024-03-03 18:04:50   at fr.ftnl.economy.bot.commands.InteractionCommandHandler.dispatch(InteractionCommandHandler.kt:72)
2024-03-03 18:04:50   at fr.ftnl.economy.bot.commands.InteractionCommandHandler$dispatch$1.invokeSuspend(InteractionCommandHandler.kt)
2024-03-03 18:04:50   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2024-03-03 18:04:50   at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:270)
2024-03-03 18:04:50   at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
2024-03-03 18:04:50   at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
2024-03-03 18:04:50   at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
2024-03-03 18:04:50   at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
2024-03-03 18:04:50   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
2024-03-03 18:04:50   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
2024-03-03 18:04:50   at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
2024-03-03 18:04:50 Caused by: java.lang.IllegalStateException: Column and factory point to different tables
2024-03-03 18:04:50   at org.jetbrains.exposed.dao.Referrers.<init>(References.kt:62)
2024-03-03 18:04:50   at org.jetbrains.exposed.dao.EntityClass.referrersOn(EntityClass.kt:324)
2024-03-03 18:04:50   at fr.ftnl.economy.database.models.BankAccount2.<init>(BankAccountTable2.kt:51)
2024-03-03 18:04:50   ... 36 more
thank you in advance for your help
a

AdamW

03/03/2024, 10:27 PM
There’s so much implicit magic going on and you should really re-consider your entity and table ”abstractions”, it’s hardly following KISS. Using objects with initializers is also completely avoidable here and I strongly recommend you avoid that pattern altogether.
b

Bastien Leveque

03/04/2024, 12:04 AM
Do you have any advice for me to do better? I learn in a completely self-taught way, I am aware of having significant gaps but I seek to improve, as a general rule I manage to find the answers to my problems through research (this research which led me to the code that I am producing today) but I was totally stuck on this question I welcome any advice
r

reformator

03/04/2024, 2:41 PM
I don't know the cause of the issue. But it involves coroutines so maybe Decoroutinator could help to localize the issue.
b

Bastien Leveque

03/04/2024, 3:29 PM
After continuing to search by speaking with a friend to get an external opinion, we found the problem which is simply an oversight that I was able to correct (a small error in a copy and paste of the declaration of my class or I did not modify one of the values whose name was similar to the one sought) I'll look at what you sent me, it might help me! If you have any other advice to give me for better practices I would be very grateful.
2 Views