Hi all,
how can i check if an entity has a parent entity which maps this entity over
Quote:
@OneToMany
annotation.
The mapping is unidirectional defined on the parent
Code:
@Entity
public class ParentEntity {
...
@OneToMany(cascade=CascadeType.ALL)
private Collection<ChildEntity> childEntities;
...
Hibernate automagically creates a mapping table, or if used
Code:
@JoinColumn
a column with the parent-id in the child table.
When the child gets persisted, hibernate adds the corresponding parent id to the db-table.
I do not want to define a bidirectional relation since i do not need this "feature" in my application-logic and there are already loads of entities which would need a change. I just need the parent for replication issues. This means i have to export some data to another DB schema (has different table structure).
I use an interceptor to trigger the replication action in the
Code:
onSave(...)
method defined by the Interceptor interface. If a parent gets a new child, there is just the persist action of the child triggering. I do not know the parent it belongs to.
I really appreciate any help!
Thanks!