Quarkus Entity Persistence Issue: "Not an entity" Error for Custom Extension

135 views Asked by At

I'm working on a Quarkus extension and facing an issue while trying to persist an entity. I have defined an entity class called ConfigurationEntity, but when I try to persist it in my main application, I receive the following error:

Error adding configuration: Not an entity [class com.acme.generalutils.runtime.configurationmanager.model.Entity.ConfigurationEntity]

Here is the code for my entity:

@Entity
@Table(name = "configuration")
public class ConfigurationEntity extends BaseEntity {
   // Fields and methods
}

In my extension, I have added a build step to register the ConfigurationEntity class:

@BuildStep
AdditionalBeanBuildItem registerConfigurationEntity() {
    return AdditionalBeanBuildItem.unremovableOf(ConfigurationEntity.class);
}

I have verified the annotations and checked my application.properties file for correct configuration, but the problem persists. I'm not using a persistence.xml file as I believe Quarkus should handle this without it.

Has anyone faced this issue before or have any ideas on what might be causing this error? Any help would be greatly appreciated!

What did I tried:

  • Ensured that all annotations are imported correctly.
  • Checked my application's application.properties for correct JPA settings.
  • Attempted a clean rebuild in development mode.
  • Looked into Jandex indexing, but I'm not sure if this is needed for my case.

Thank you in advance for any insights!

1

There are 1 answers

0
Guillaume Smet On

I'm not sure why you are developing a Quarkus extension? You don't need an extension to add Hibernate ORM entities to a Quarkus application. Also you can simply put the entities in a separate library jar (just a simple jar, not an extension) and as long as you index it with the Jandex Maven plugin, they will be discovered by Quarkus. But let's consider you actually need an extension.

Hibernate ORM entities are not beans so you shouldn't use AdditionalBeanBuildItem, this is to register CDI beans.

You have AdditionalJpaModelBuildItem to register additional entities from an extension. But indexing the runtime jar with the Jandex Maven plugin should also work if your model is getting complex and AdditionalJpaModelBuildItem becomes impractical. Note that you need to add all entities via this build item, Quarkus won't follow the JPA relationships to discover other entities.