I have been trying to cache an entity in hibernate hazelcast. This entity is dependent on another entity. I have tried the mapping in the following ways. The first one caches after first em.find
but the second one doesn’t.
@Entity
@Table(name = "config")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "hibernate-average-config")
public class Config implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "foreignIdGenerator")
@GenericGenerator(
name = "foreignIdGenerator", strategy = "foreign",
parameters = @Parameter(name = "property", value = "provider"))
private int id;
@Fetch(SELECT)
@OneToOne(optional = false)
@JoinColumn(name = "prov_id", nullable = false, updatable = false, unique = true)
private Provider provider;
This above snippet works but the following does not
@Entity
@Table(name = "config")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "hibernate-average-config")
public class Config implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@MapsId
@Fetch(SELECT)
@OneToOne(optional = false)
@JoinColumn(name = "prov_id", unique = true, nullable = false, updatable = false)
private Provider provider;