this is the trace from hibernate:
2008-11-10 17:27:22,470 DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport: create table ms_alias_buddy_login_mapping (buddy_login_id bigint not null, buddy_alias_id bigint not null, primary key (buddy_login_id, buddy_alias_id))
2008-11-10 17:27:22,472 DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport: create table ms_buddy_alias (id bigint generated by default as identity (start with 1), id_identity_id bigint not null, alias varchar(255) not null, created timestamp, updated timestamp, primary key (id))
2008-11-10 17:27:22,472 DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport: create table ms_buddy_login (id bigint generated by default as identity (start with 1), login varchar(255), created timestamp, provider_id bigint not null, primary key (id), unique (login, provider_id))
2008-11-10 17:27:22,475 DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport: create table ms_network_login (id bigint generated by default as identity (start with 1), id_identity_id bigint not null, login varchar(255) not null, password longvarbinary not null, priority integer not null, network varchar(255) not null, state varchar(255), removedAt timestamp, created timestamp, primary key (id), unique (id_identity_id, login, network))
2008-11-10 17:27:22,476 DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport: create table ms_provider (id bigint not null, name varchar(255), type varchar(255), primary key (id))
2008-11-10 17:27:22,476 DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport: alter table ms_alias_buddy_login_mapping add constraint FK6260C677C868F8BB foreign key (buddy_alias_id) references ms_buddy_login
2008-11-10 17:27:22,476 DEBUG [main] org.hibernate.tool.hbm2ddl.SchemaExport: alter table ms_alias_buddy_login_mapping add constraint FK6260C6778A1BFAA9 foreign key (buddy_login_id) references ms_buddy_alias
from my point of view it looks like there is a foreign key from the mapping to its parent table.
Consequently removing an entry from a parent should automatically remove its child entry.
The log informs me about the removal:
2008-11-10 17:27:23,487 DEBUG [main] org.hibernate.engine.StatefulPersistenceContext: initializing non-lazy collections
2008-11-10 17:27:23,487 TRACE [main] org.hibernate.event.def.DefaultLoadEventListener: loading entity: [com.steademy.service.ms.domain.BuddyLoginEntity#3]
2008-11-10 17:27:23,487 TRACE [main] org.hibernate.event.def.DefaultLoadEventListener: attempting to resolve: [com.steademy.service.ms.domain.BuddyLoginEntity#3]
2008-11-10 17:27:23,487 TRACE [main] org.hibernate.event.def.DefaultLoadEventListener: resolved object in session cache: [com.steademy.service.ms.domain.BuddyLoginEntity#3]
2008-11-10 17:27:23,487 TRACE [main] org.hibernate.event.def.DefaultDeleteEventListener: deleting a persistent instance
2008-11-10 17:27:23,487 TRACE [main] org.hibernate.event.def.DefaultDeleteEventListener: deleting [com.steademy.service.ms.domain.BuddyLoginEntity#3]
2008-11-10 17:27:23,487 TRACE [main] org.hibernate.impl.SessionImpl: setting cache mode to: GET
2008-11-10 17:27:23,488 TRACE [main] org.hibernate.impl.SessionImpl: setting cache mode to: NORMAL
2008-11-10 17:27:23,488 TRACE [main] org.hibernate.impl.SessionImpl: setting cache mode to: GET
2008-11-10 17:27:23,488 TRACE [main] org.hibernate.impl.SessionImpl: setting cache mode to: NORMAL
My tests reveal that the entity itself has been properly removed, the enty within the mapping entity (the child) though is still available.
any idea ??
|