Article View: pl.comp.lang.java
Article #143570Re: hibernate mapowanie kluczy obcych xml
From: mk
Date: Sat, 10 Jan 2009 10:12
Date: Sat, 10 Jan 2009 10:12
69 lines
2490 bytes
2490 bytes
Jarek pisze:
> Tak, klasa Listy będzie zbędna.
> A do klas Osoba i Lista musisz dodać odpowiednio pola (najlepiej od razu
> zainicjalizowane):
>
> Set<Lista> listy = new HashSet<Lista>();
>
> oraz
>
> Set<Osoba> osoby = new HashSet<Osoba>();
>
> no i odpowiednie gettery i settery.
>
> Pozdrawiam
> Jarek
Zdecydowałem się ostatecznie, na takie coś:
[osoby.hbm.xml]
<set name="listy" table="listy" cascade="all">
<key column="id_os"/>
<many-to-many column="id" class="Lista"/>
</set>
[Osoby.java]
private Set listy;
public Set getListy(){
return this.listy;
}
public void setListy(Set listy){
this.listy=listy;
}
[lista.hbm.xml]
<set name="osoby" table="listy">
<key column="id_lista"/>
<many-to-many column="id" class="Osoby"/>
</set>
[Lista.java]
private Set osoby;
public Set getOsoby(){
return this.osoby;
}
public void setOsoby(Set osoby){
this.osoby=osoby;
}
I ładnie tworzy mi tabelkę łączącą
[listy]
id_os
id
id_lista
Wydaje mi się, że jest ok, mógłbyś zerknąć czy czegoś nie przegapiłem?
Teraz będę chciał wpisać kilka osób na listę, jak to powinno się zrobić,
coś kojarzę batch processing w hibernate, to tym tropem szukać?
dzięki
pozdr.
mk
Technical Details
Message-ID:
<gk9seg$t59$1@atlantis.news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.neostrada.pl!nemesis.news.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mailReferences:
<gk4i5e$hou$1@atlantis.news.neostrada.pl> <gk632c$7lf$1@inews.gazeta.pl> <gk854t$jo1$1@nemesis.news.neostrada.pl> <gk86qe$91c$1@inews.gazeta.pl> <gk892b$pi2$1@nemesis.news.neostrada.pl> <gk8ath$2og$1@inews.gazeta.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.onet.pl!newsfeed.neostrada.pl!nemesis.news.neostrada.pl!atlantis.news.neostrada.pl!news.neostrada.pl!not-for-mail From: mk <mk@mk.pl> Newsgroups: pl.comp.lang.java Subject: Re: hibernate mapowanie kluczy obcych xml Date: Sat, 10 Jan 2009 11:12:50 +0100 Organization: TP - http://www.tp.pl/ Lines: 69 Message-ID: <gk9seg$t59$1@atlantis.news.neostrada.pl> References: <gk4i5e$hou$1@atlantis.news.neostrada.pl> <gk632c$7lf$1@inews.gazeta.pl> <gk854t$jo1$1@nemesis.news.neostrada.pl> <gk86qe$91c$1@inews.gazeta.pl> <gk892b$pi2$1@nemesis.news.neostrada.pl> <gk8ath$2og$1@inews.gazeta.pl> NNTP-Posting-Host: acov134.neoplus.adsl.tpnet.pl Mime-Version: 1.0 X-Trace: atlantis.news.neostrada.pl 1231582480 29865 83.10.201.134 (10 Jan 2009 10:14:40 GMT) X-Complaints-To: usenet@news.neostrada.pl NNTP-Posting-Date: Sat, 10 Jan 2009 10:14:40 +0000 (UTC) User-Agent: Thunderbird 2.0.0.19 (X11/20090105) In-Reply-To: <gk8ath$2og$1@inews.gazeta.pl> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit