-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
javax.persistence.PersistenceException: Database [null] was not found? when accessing OneToMany property #2861
Comments
|
update: I've updated to java 17 and ebean 13.5.0 and the problem persists, tried to upgrade to 13.6.0, but I'm having some problem with initialization of one of the entity bean classes, specifically Caused by: java.lang.IllegalStateException: Error trying to create the prototypeEntityBean for class cz.sentica.qwazar.ea.core.entities.EaObjectProperty
at io.ebeaninternal.server.deploy.BeanDescriptor.createPrototypeEntityBean(BeanDescriptor.java:431)
at io.ebeaninternal.server.deploy.BeanDescriptor.<init>(BeanDescriptor.java:246)
at io.ebeaninternal.server.deploy.BeanDescriptorManager.registerDescriptor(BeanDescriptorManager.java:620)
at io.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityRelationships(BeanDescriptorManager.java:735)
at io.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:295)
at io.ebeaninternal.server.core.InternalConfiguration.<init>(InternalConfiguration.java:128)
at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:109)
at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:34)
at io.ebean.DatabaseFactory.createInternal(DatabaseFactory.java:136)
at io.ebean.DatabaseFactory.create(DatabaseFactory.java:85)
at cz.sentica.qwazar.ea.test.TestEaPersistenceConfiguration.eaDatabase(TestEaPersistenceConfiguration.kt:33)
at cz.sentica.qwazar.ea.test.TestEaPersistenceConfiguration$$EnhancerBySpringCGLIB$$108ad610.CGLIB$eaDatabase$4(<generated>)
at cz.sentica.qwazar.ea.test.TestEaPersistenceConfiguration$$EnhancerBySpringCGLIB$$108ad610$$FastClassBySpringCGLIB$$1144e9fb.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)
at cz.sentica.qwazar.ea.test.TestEaPersistenceConfiguration$$EnhancerBySpringCGLIB$$108ad610.eaDatabase(<generated>)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
... 107 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at io.ebeaninternal.server.deploy.BeanDescriptor.createPrototypeEntityBean(BeanDescriptor.java:429)
... 127 more
Caused by: java.lang.InstantiationError: io.ebean.bean.EntityBeanIntercept
at cz.sentica.qwazar.ea.core.entities.EaObjectProperty.<init>(EaConnector.kt:1)
... 133 more for a bean class defined as @Entity
@DbName("ea")
@Table(name = "T_OBJECTPROPERTIES")
data class EaObjectProperty(
@Id
@Column(name = "PROPERTYID", nullable = false)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "t_objectproperty_sequence_generator",
)
@SequenceGenerator(
name = "t_objectproperty_sequence_generator",
sequenceName = "PROPERTYID_SEQ",
allocationSize = 1,
)
var id: Long = 0,
@Column(name = "PROPERTY")
var property: String? = null,
@Column(name = "Value") // Case je spravne - alespon pro firebird databazi.
var value: String? = null,
@Column(name = "NOTES")
@Lob
var notes: String? = null,
@Column(name = "EA_GUID")
var eaGuid: String? = null,
@ManyToOne
@JoinColumn(name = "OBJECT_ID", nullable = false)
@JsonIgnore
var eaObject: EaObject,
) : Serializable {
companion object {
const val VALUE_MAXLEN = 255
}
} will investigate further update: this doesn't seem to be related to that specific entity - getting the same for other entity classes |
I created a minimal repository to reproduce this problem here https:/Incanus3/ebean-test it has only those two entities and the test from above. In this repository I was able to upgrade ebean to the latest version without encountering the "java.lang.InstantiationError: io.ebean.bean.EntityBeanIntercept" problem, so I guess it's some problem with our setup. But the "Database [null] not found" problem is still there. |
btw what's even more surprising to me is that this fails even if I set all the |
Damn, I just found the problem - this happens if I use the Anyway, I'm sorry for taking up your time and thank you for this great library, I really enjoy using it (until I make a stupid mistake :). |
Excellent work, well done.
I've had a closer look at this and its actually the initialization of the list to kotlin.collections.CollectionsKt.emptyList() ... and it's this initialisation that Ebean is not expecting and handling correctly. emptyList() - Does not workThe use of @OneToMany(...)
var outgoingConnections: List<EaConnector> = emptyList() // this will NOT work arrayListOf() - WorksInitialising using @OneToMany(...)
var outgoingConnections: List<EaConnector> = arrayListOf() // this will work ... and of courseAnd @OneToMany(...)
var incomingConnections: MutableList<EaConnector> = arrayListOf()
I'm pretty sure we can handle this case.
I feel your pain but I know I would have looked at The big positive is that this is a really nice issue to find because I'd suggest other people will very likely hit this plus this is a really nice little test app showing us the problem so we have every chance of sorting this!! Cheers, Rob.
Yeah, I need to explain a bit more on what is going on, why ebean is handling the "initialisation of OneToMany and ManyToMany". Some internal details to explain at some point which are actually harder to see in Kotlin in that IntelliJ doesn't easily offer up the bytecode view - need to use ASM plugin etc. |
Hi. Ooh, |
Fixed by ebean-orm/ebean-agent#191 Upgrading the ebean gradle plugin to |
Expected behavior
Actual behavior
Steps to reproduce
The environment
we're using
Also
The text was updated successfully, but these errors were encountered: