Error reading annotations for class

25 views
Skip to first unread message

stackp...@gmail.com

unread,
Apr 5, 2023, 3:17:28 AM4/5/23
to Ebean ORM
Hello,

First of all I was working with a single database and I didn't have any problems. Now I want to use 2 databases for different reasons and I am trying to move some entities and that's when I get the following error:

Error in deployment
java.lang.RuntimeException: Error reading annotations for generalModels.Allergen
Caused by: io.ebean.config.BeanNotRegisteredException: Error with association to [class models.Product] from [generalModels.Allergen.products]. Is class models.Product registered?

The definitions of the clases are:

@Entity
public class Allergen extends Model {
...
@ManyToMany(mappedBy="allergens")
private List<Product> products = new ArrayList<>();

public static Finder<Integer, Allergen> find = new Finder<>(Allergen.class, "general");
}

@Entity
public class Product extends Model {
...
@ManyToMany
public List<Allergen> allergens = new ArrayList<>();


Do you know how I can fix it? Thanks

Jens

unread,
Apr 5, 2023, 5:34:54 AM4/5/23
to Ebean ORM
Ebean has the concept of different databases via its Database class. There is a default database and there are named databases. If you do not configure your entity for a specific database the entity is registered with the default database. To assign an entity to a specific database you can use the annotation @DbName("MY_DATABASE") and then provide a configuration for database MY_DATABASE (see DatabaseConfig.setName()), so ebean knows how to connect to it.

You can also apply the annotation to an abstract class annotated with @MappedSuperclass. Then you can entities for a given database extend that abstract class.

stackp...@gmail.com

unread,
Apr 10, 2023, 3:49:47 AM4/10/23
to Ebean ORM
I think the problem is different because if I comment the association between the two entities, the application works fine and it is possible to create objects of them.
I believe that the problem is ManyToMany because this generate a new entity automatically and maybe Ebean does not know how to manage it or where to create it.
Reply all
Reply to author
Forward
0 new messages