@Entity
public class Foo implements Serializable {
@Id
@GeneratedValue
String id;
@ElementCollection
Set<Bar> bars;
}
@Embeddable
public class Bar {
@Embedded
Baz baz;
}
@Embeddable
class Baz {
String property;
}
I get the error:
2022-10-25 16:01:06,124 ERROR [io.qua.run.Application] (Quarkus Main Thread) Failed to start application (with profile dev): java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at org.hibernate.persister.collection.AbstractCollectionPersister.generateSelectSizeString(AbstractCollectionPersister.java:1048)
at org.hibernate.persister.collection.AbstractCollectionPersister.<init>(AbstractCollectionPersister.java:522)
at org.hibernate.persister.collection.BasicCollectionPersister.<init>(BasicCollectionPersister.java:59)
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 org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:152)
at org.hibernate.persister.internal.PersisterFactoryImpl.createCollectionPersister(PersisterFactoryImpl.java:140)
at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:226)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:319)
at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:74)
at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:72)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:165)
at io.quarkus.hibernate.orm.runtime.JPAConfig$1.run(JPAConfig.java:66)
at java.base/java.lang.Thread.run(Thread.java:833)
I don’t know if it helps but earlier in the application log there’s this:
2022-10-25 16:01:05,544 DEBUG [org.hib.cfg.CollectionSecondPass] (Quarkus Main Thread) Second pass for collection: com.example.Foo.bars
2022-10-25 16:01:05,544 DEBUG [org.hib.cfg.ann.CollectionBinder] (Quarkus Main Thread) Binding a collection of element: com.example.Foo.bars
2022-10-25 16:01:05,547 DEBUG [org.hib.cfg.Ejb3Column] (Quarkus Main Thread) Binding column: Ejb3Column{table=org.hibernate.mapping.Table(Foo_bars), mappingColumn=baz, insertable=true, updatable=true, unique=false}
2022-10-25 16:01:05,547 DEBUG [org.hib.cfg.ann.PropertyBinder] (Quarkus Main Thread) Building property baz
2022-10-25 16:01:05,548 DEBUG [org.hib.map.PrimaryKey] (Quarkus Main Thread) Forcing column [foo_id] to be non-null as it is part of the primary key for table [foo_bars]
2022-10-25 16:01:05,548 DEBUG [org.hib.cfg.CollectionSecondPass] (Quarkus Main Thread) Mapped collection key: Foo_id, element: