<div dir="ltr">conpota$B$H?=$7$^$9!#(B<br><br>S2JDBC$B$r;n$7$F$$$^$9!#(B<br>$B0J2<%F!<%V%k$,$"$C$?$H$7$F!"(B<br><br>CREATE TABLE one(<br> id SERIAL PRIMARY KEY,<br> name VARCHAR(64) NOT NULL<br>);<br>insert into one(name) values('one1');<br>insert into one(name) values('one2');<br>
<br>CREATE TABLE two(<br> id SERIAL PRIMARY KEY,<br> name VARCHAR(64) NOT NULL<br>);<br>insert into two(name) values('two1');<br>insert into two(name) values('two2');<br><br>CREATE TABLE three(<br> id SERIAL PRIMARY KEY,<br>
name VARCHAR(64) NOT NULL<br>);<br>insert into three(name) values('three1');<br>insert into three(name) values('three2');<br><br>CREATE TABLE one_two(<br> id SERIAL PRIMARY KEY,<br> one_id INTEGER NOT NULL,<br>
two_id INTEGER NOT NULL,<br> FOREIGN KEY (one_id) REFERENCES one (id),<br> FOREIGN KEY (two_id) REFERENCES two (id)<br>);<br>insert into one_two(one_id, two_id) values(2, 1);<br>insert into one_two(one_id, two_id) values(2, 2);<br>
<br>CREATE TABLE two_three(<br> id SERIAL PRIMARY KEY,<br> two_id INTEGER NOT NULL,<br> three_id INTEGER NOT NULL,<br> FOREIGN KEY (two_id) REFERENCES two (id),<br> FOREIGN KEY (three_id) REFERENCES three (id)<br>);<br>
insert into two_three(two_id, three_id) values(1, 1);<br>insert into two_three(two_id, three_id) values(2, 1);<br><br>$B$3$l$i$N%(%s%F%#%F%#%/%i%9$N4XO"%W%m%Q%F%#$r0J2<$N$h$&$K=q$-$^$7$?!#(B<br><br>One$B%(%s%F%#%F%#(B<br>@ManyToOne<br>public OneTwo oneTwo;<br><br>Two$B%(%s%F%#%F%#(B<br>
@OneToOne(mappedBy = "two")<br>public OneTwo oneTwo;<br>@OneToOne(mappedBy = "two")<br>public TwoThree twoThree;<br><br>Three$B%(%s%F%#%F%#(B<br>@ManyToOne<br>public TwoThree twoThree;<br><br>OneTwo$B%(%s%F%#%F%#(B<br>@OneToOne<br>
public Two two;<br>@OneToMany(mappedBy = "oneTwo")<br>public List<One> oneList;<br><br>TwoThree$B%(%s%F%#%F%#(B<br>@OneToOne<br>public Two two;<br>@OneToMany(mappedBy = "twoThree")<br>public List<Two> twoList;<br>
<br>$B$=$7$F(BService$B%/%i%9$G0J2<$N$h$&$K(B<br>Two two = jdbcManager.from(Two.class).innerJoin("oneTwo").where("name = ?", "two1").getSingleResult();<br>$B$9$k$H0U?^DL$j$N7k2L$,<hF@$G$-$^$9!#(B<br>$B$5$i$K%F!<%V%k$r7k9g$7$F(B<br>Two two = jdbcManager.from(Two.class).innerJoin("oneTwo").innerJoin("oneTwo.oneList").where("name = ?", "two1").getSingleResult();<br>
$B$H$9$k$H0J2<%(%i!<$K$J$j$^$9!#(B<br>$B%(%s%F%#%F%#(B(One)$B$N%W%m%Q%F%#(B(oneTwo)$B$,IT@5$G$9!#(BJoinColumn$B$N(Bname$B$G;XDj$5$l$F$$$k30It%-!<(B(ONE_TWO_ID)$B$,B8:_$7$^$;$s!#(B<br>$B:G=*E*$KA4$F$N%F!<%V%k$r(BinnerJoin$B$7$?$$$N$G$9$,!"(B<br>$B$I$&$9$l$P$h$$$G$7$g$&$+!)(B<br><br>$B$h$m$7$/$*4j$$CW$7$^$9!#(B<br clear="all"><br>-- <br>conpota <<a href="mailto:conpota@gmail.com">conpota@gmail.com</a>><br>
</div>