I have two multi-module applications in two unit classes with two different modules I one unit one on one another - There is a relationship with each other.
The primary unit "song" is a module song-core and it is defined in such a way:
@Entity Public Class Song {@ ID (strategy = Generation type Ind.TT Private Ent ID; The name of the private string; } and the next unit module called "Song Lyrics" is from the "song-song" module, which is defined in some way: @Entity Public Square Song Lyrics {@Id (strategy = GenerationType.IDENTITY) Private INAD; @OneToOne private song song; @column (drain = false, length = 1024) Private string song; } Since the SongLyrics unit is an optional "song-song" module, which may or may be available in the final app, there is a directional with the "song" unit in the < / P> Now I want the "Songline" body to be removed, whenever the "Song" unit is destroyed. But now what is happening is left in the form of "song songs" institutions "orphan" and only "song" institutions are being destroyed.
Please give your insights on this Thank you.
song songs it can not be an identity in one-one-one Relationships one-to-one mean they share the same primary key when using a common foreign key in the database to point to SongLyrics to song , This is a very many relationship. The problem is that there is no connection with song to SongLyrics , so cascading from hibernate does not work. P> These are the alternatives to my mind:
- From
song to SongLyrics Reduce any kind of build relationships and still be able to cascade (and navigate). - Use a kind of event in your app to inform the module, when some are removed, so that they can be allowed to clean (or veto).
- Use the database trigger to remove
SongLyrics .
Comments
Post a Comment