-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Many to many save and delete relation table only.
PostPosted: Thu May 29, 2008 12:32 am 
Newbie

Joined: Thu May 29, 2008 12:02 am
Posts: 2
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 29, 2008 1:12 am 
Newbie

Joined: Thu May 29, 2008 12:02 am
Posts: 2
So I don't know what happens but after night all works. So if someone can delete this solved problem. Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.