I have the following entities
@JsonInclude(JsonInclude.Include.NON_NULL)
@Embeddable
public class EmbeddableEntity
{
@Cascade(CascadeType.SAVE_UPDATE)
@OneToOne
@JoinColumn(name = "fk_entity_A")
private EntityA entityA;
}
@Entity
@Table(name = "tb_entity_a")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type", length = 50)
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class EntityA
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@JsonIgnore
protected Long id;
@JsonIgnore
@OneToOne(mappedBy = "embeddableEntity.entityA", orphanRemoval = true)
protected EntityB entityB;
@NotNull
@Column(name = "boolean_field", columnDefinition = "TINYINT DEFAULT 0", nullable = false)
private Boolean booleanField = false;
}
@Entity
@Table(name = "tb_entity_b")
@DiscriminatorColumn(name = "type", length = 50)
@DiscriminatorValue("entityb")
public class EntityB
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Embedded
private EmbeddableEntity embeddableEntity;
}
I want JPAMetaModelEntityProcessor to generate a MetaModel class like this:
package br.com.loopec.loopkey.server.corp.persistence.entity;
import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(EmbeddableEntity.class)
public abstract class EmbeddableEntity_ {
public static volatile SingularAttribute<EmbeddableEntity, EntityB> entityB;
public static volatile SingularAttribute<EmbeddableEntity, Boolean> booleanField;
public static final String ENTITY_B = "entityB";
public static final String BOOLEAN_FIELD = "booleanField";
}
But all it generates for me is a class like this, omitting the entityB field I want generated:
package br.com.loopec.loopkey.server.corp.persistence.entity;
import javax.annotation.Generated;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(EmbeddableEntity.class)
public abstract class EmbeddableEntity_ {
public static volatile SingularAttribute<EmbeddableEntity, Boolean> booleanField;
public static final String BOOLEAN_FIELD = "booleanField";
}
I don’t know it’s useful information, but I’ve been facing this problem building the project from Docker.
My version of hibernate is: 5.4.15.Final
Can you see if I did something wrong with my code? I don’t know if it’s a hibernate bug, but I found a thread on stack overflow with another developer having a similar problem. JPA Hibernate 5: OneToOne in nested Embeddable causes metamodel issue - Stack Overflow