First info: I'm using:
Hibernate Annotations 3.4.0.GA
I need help about creating properly structure of db. Probably I don't good understand or I did mistake. I have some entities (File, Music, Playout, Playout_Files, Playout_Music) and I want that one object Playout have some File's and Music's for example:
Everything is OK, next I want add new entity Playout, example:
I've got error:
I understand that we cannot use the same item File and/or Music used in first Playout.
I tried use (the same for Music)
But it looks like wrong, I cannot explain it good..
How should I change structure/mapping that I can use again used item File?
I think you're telling us half of the truth. In your example you invoke the constructor: new Playout(2, 'Title2', files, musics)
Yet the class Playout only has the constructors: public Playout() & public Playout(String filetitle, Set<File> files, Set<Music> musics)
Maybe a typo.
Also why do you initialize musics but not versionFiles in Playout?
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Thank you for reply. You are right.. I said half of the truth.. I wrote it from member, Some code I was simplied for readers. I'll put whole methods:
I fixed code in Playout.java, initialization at begin code:
Eclipse recompiled whole code, next deploy on tomcat.
I started browser, clicked first time (I selected first Music, first File, entered name title of Playout and time)
and I see that it saved into db. Next I put new name title of Playout and time, selected again first Music, first File. And I've got error that:
When I selected second file from tableFile, second music from tableMusic it wrote successfully.
The problem in my opinion is in wrong structure that I cannot save the same Music/File used again as new entity Playout. Any ideas?
OK, I'm read again book about Hibernate and I see that I did one mistake. It should be mapping @ManyToMany because entity File is used more than one in various entities Playout. The same is for entity Music.
We find this kind of rampant individuality very disturbing. But not this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss