Hi guys,
I am learning hibernate and SWT so I am wirting home application for movies.
So my problem.
I have three tables.
t_movies
id
......
r_movie_actor
id_movie
id_actor
t_actor
id
......
eclipse plugin generate for me this code.
t_movie
Code:
....
<set name="TActors" table="r_movie_actor">
<key>
<column name="id_movie" not-null="true">
<comment></comment>
</column>
</key>
<many-to-many entity-name="gb.mov.hib.TActor">
<column name="id_actor" not-null="true">
<comment></comment>
</column>
</many-to-many>
</set>
....
t_actor
Code:
...
<set name="TMovies" table="t_actor">
<key>
<column name="id_actor" not-null="true">
<comment></comment>
</column>
</key>
<many-to-many entity-name="gb.mov.hib.TMovie">
<column name="id_movie" not-null="true">
<comment></comment>
</column>
</many-to-many>
</set>
...
And now what my problem.
I wannt this.
A) when I add movie
- insert into t_movie
- insert into r_movie_actor
B) when I delete movie
- delete from t_movie where id=?
- delete from r_movie_actor where id_movie = id from t_movie
- not delete from t_actor!!!
C) when I delete actor
- delete from t_actor where id=?
- delete from r_movie_actor where id_actor = id from t_actor
- not delete from t_movie!!!
So my questions are.
1) It's possible configure hibernate to do it?
2) How to do it ? I tried cascade all in both sets, but result is delete actors when I delete movie but I wannt delete only from r_movie_actor.
Thanks for any idea.
Sorry for my English.
Regards Georg Black