Illegal argument on static metamodel field injection - json type [HHH015007]

Hi!

After adding the annotation processor hibernate-jpamodelgen there are errors in logs on application startup:

ERROR org.hibernate.metamodel.internal.MetadataContext - HHH015007: Illegal argument on static metamodel field injection : com.example.Group_#products; expected type :  org.hibernate.metamodel.model.domain.internal.SingularAttributeImpl; encountered type : javax.persistence.metamodel.ListAttribute

I am mapping json collection to List, just like in How to map a JSON collection using JPA and Hibernate - Vlad Mihalcea. The mapping works fine, but how can I fix metamodel, so that Group_#products wouldn’t be null? Do you have any suggestions how to manage with this error?

My entity looks like this:

@Entity
@Access(FIELD)
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
class Group {

	@Type(type = "jsonb")
	@Column(columnDefinition = "json")
	List<Product> products;
}

Generated metamodel looks like this:

public abstract class Group_ {

	public static volatile ListAttribute<Group, Product> products; // null after startup

	public static final String PRODUCTS = "products";
}

Hibernate version - 5.4.33.Final
Database - postgres
Products column type - jsonb

Try annotating the field with @Basic. Also, you should at least try to update to ORM 5.6

Thanks for the response! Unfortunately @Basic did not fix it, error message remained the same.

Right now we are on a way to 5.5. Hope to upgrade to 5.6 soon :slight_smile: