Hello,
i'm using following mapping:
Code:
@CollectionOfElements(fetch=FetchType.EAGER)
@JoinTable(name = "SCHEMA_ENTRY", joinColumns = @JoinColumn(name = "SCHEMA_FK", nullable = false))
@MapKeyManyToMany(joinColumns = @JoinColumn(name = "ENTRY_FK", nullable = false), targetEntity = NotificationSchemaEntry.class)
@Column(name = "ALLOWED")
@Target(NotificationSchema.class)
@Cascade({ALL,DELETE_ORPHAN})
@Fetch(FetchMode.JOIN)
private Map<NotificationSchemaEntry, Boolean> entries;
the resulted mapping is correct and the application works fine, but if i need to load the schema by traversing the corresponding attribute tree of entity "user" (user.getNotificationSchema()) the entries will not be loaded eager but as 1+n select. Also FetchMode.SUBSELECT didn't work.
Also @Cascade option doesn't persist the entries as expected. Do i need any backreference on entry? The resulted relation seems to be ok:
Code:
CREATE TABLE schema_entry
(
schema_fk bigint NOT NULL,
allowed boolean,
entry_fk bigint NOT NULL,
CONSTRAINT schema_entry_pkey PRIMARY KEY (schema_fk, entry_fk),
CONSTRAINT fk74ca203436c32af0 FOREIGN KEY (entry_fk)
REFERENCES notification_schema_entry (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk74ca2034ff60e990 FOREIGN KEY (schema_fk)
REFERENCES notification_schema (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
I would be grateful for any hint.
Thanks, Gena.