I am trying to add a Transient property to my Embeddable class. Here is what I have:
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@Embeddable
public class PackageProduct
{
@Field
private String productId;
@Transient
private Product product;
}
And PackageProduct is used in Package.java like this;
@ElementCollection(targetClass=PackageProduct.class, fetch = FetchType.EAGER)
private Set<PackageProduct> packageProducts;
However, this throws the following exception:
Caused by: org.hibernate.MappingException: Could not determine type for: *.*.*.Product, at table: Package_packageProducts, for columns: [org.hibernate.mapping.Column(packageProducts.product)]
The exception is no longer thrown if I annotate my PackageProduct class with this:
@Access(AccessType.FIELD)
I am trying to understand why it works with the class level @Access annotation. Any help is appreciated. Thanks.
In hibernate either you can apply all annotations on fields or methods, simultaneously mix use is not allow.To override this @Access
is needed.In your product class if you are using such case, rectify this.