25分でわかるJPA/jpa-in-25min

 25分でわかるJPA/jpa-in-25min

2017-07-26 JJUGナイトセミナー「O/Rマッパー特集」のJPAの資料です。

5dbaf4015e7f249ab21b195ced8e9e46?s=128

Masatoshi Tada

July 26, 2017
Tweet

Transcript

  1. (C) CASAREAL, Inc. All rights reserved. ෼Ͱ ೉͕͠͞ ෼͔Δ
 +1"

    ג ΧαϨΞϧଟాਅහ ++6(φΠτηϛφʔ03Ϛούʔಛू ೥݄೔ ਫ 1
  2. (C) CASAREAL, Inc. All rights reserved. ͜ͷηογϣϯʹ͍ͭͯ ▸ ʹԬࢁ+BWBϢʔβձͰൃදͨ͠
 ʮ෼ͰΘ͔Δ4QSJOH%BUB+1"ʯͷൈਮ൛Ͱ͢

    ▸ ࢿྉˠIUUQTTQFBLFSEFDLDPNNBTBUPTIJUBEB TQSJOHEBUBKQBJONJO ▸ αϯϓϧίʔυ͸(JU)VCʹ͋Γ·͢ ▸ IUUQTHJUIVCDPN.BTBUPTIJ5BEBTQSJOHEBUBKQB EBJUPLBJ 2
  3. (C) CASAREAL, Inc. All rights reserved. ࣗݾ঺հ ▸ ଟాਅහʢ!TVLF@NBTBʣ ▸

    ݚमτϨʔφʔ!ΧαϨΞϧ ▸ +BWB&&ߨࢣ1JWPUBMೝఆߨࢣ ▸ ೔ຊ4QSJOHϢʔβʔձελοϑ ▸ ೔ຊ(MBTT'JTIϢʔβʔձӡӦϝϯόʔ ▸ ++6($$$͸ճ࿈ଓొஃத 3
  4. (C) CASAREAL, Inc. All rights reserved. (MBTT'JTIϢʔβʔձ͔ΒϓϨθϯτʂ ▸ 1BZBSB5γϟπ ▸

    9-ºݶఆຕʂ ▸ ཉ͍͠ํ͸͋ͱͰ
 ੠Λ͔͚͍ͯͩ͘͞ʂ 4
  5. (C) CASAREAL, Inc. All rights reserved. ᶃ +1"ͱ͸ʁ ᶄ +1"ΤϯςΟςΟͷঢ়ଶ؅ཧ

    ᶅ +BWB1FSTJTUFODF2VFSZ-BOHVBHF +12-  ᶆ ϦϨʔγϣϯͱ/ ໰୊ରࡦ ᶇ ࠓճ͸঺հͰ͖ͳ͔ͬͨػೳ ᶈ +1"͸ʮ࢖͑Δʯͷ͔ʁ 5
  6. (C) CASAREAL, Inc. All rights reserved. ᶃ +1"ͱ͸ʁ ᶄ +1"ΤϯςΟςΟͷঢ়ଶ؅ཧ

    ᶅ +BWB1FSTJTUFODF2VFSZ-BOHVBHF +12-  ᶆ ϦϨʔγϣϯͱ/ ໰୊ରࡦ ᶇ ࠓճ͸঺հͰ͖ͳ͔ͬͨػೳ ᶈ +1"͸ʮ࢖͑Δʯͷ͔ʁ 6
  7. (C) CASAREAL, Inc. All rights reserved. +1"ͱ͸ʁ ▸ +BWB&&ͷҰ෦ͱͯ͠ඪ४Խ ͞ΕͨσʔλΞΫηεٕज़ͷ

    ࢓༷ ▸ ࣮ମ͸+43ͱ͍͏จॻ ▸ ܾ·ͬͯΔͷ͸ΠϯλϑΣʔεɾ Ξϊςʔγϣϯɾྫ֎͕΄ͱΜ Ͳ 7 ໿600ϖʔδ
  8. (C) CASAREAL, Inc. All rights reserved. +1"࣮૷ϥΠϒϥϦ ᶃ )JCFSOBUF ▸

    03Ϛούʔͷ૲෼͚తଘࡏ ▸ 4QSJOH%BUB+1"͸جຊతʹίϨ ᶄ &DMJQTF-JOL ▸ +1"ͷࢀর࣮૷ ▸ (MBTT'JTI8FC-PHJDͳͲʹ಺แ 8 ࠓճ͸ίϨ ※ଞͷ࣮૷͸JPA 2.1(Java EE 7)ʹ
 ɹରԠ͍ͯ͠ͳ͍
  9. (C) CASAREAL, Inc. All rights reserved. +1"ͷಛ௃ ▸ %#੡඼ʹґଘ͠ͳ͍ૢ࡞͕هड़Ͱ͖Δ ▸

    ΤϯςΟςΟΛςʔϒϧͱରͰ࡞Δ ▸ ʮ4&-&$5ͷ݁ՌͱରʯͰ͸ͳ͍ͷͰ஫ҙʂ ▸ ରଟͷΑ͏ͳϦϨʔγϣϯΛදݱͰ͖Δ 9
  10. (C) CASAREAL, Inc. All rights reserved. QPNYNM 10 <dependency> <groupId>org.hibernate</groupId>

    <artifactId>hibernate-entitymanager</artifactId> <version>5.0.12.Final</version> </dependency> <dependency> <groupId>ch.qos.logbask</groupId> <artifactId>logback-classic</artifactId> <version>1.1.11</version> </dependency>
  11. (C) CASAREAL, Inc. All rights reserved. 42-ϩάͷग़ྗ͸ඞਢʂ ▸ τϥϒϧγϡʔςΟϯάͰॏཁʂ 11

    <logger name="org.hibernate.SQL" level="DEBUG" /> <logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" /> ▸ MPHCBDLYNMʹԼهΛઃఆ ※hibernate.show_sql=trueͩͱϩάͷϑΥʔϚοτΛࢦఆͰ͖ͳ͍ͷͰ͜ΕΒͷํ๏͕Φεεϝ
  12. (C) CASAREAL, Inc. All rights reserved. ᶃ +1"ͱ͸ʁ ᶄ +1"ΤϯςΟςΟͷঢ়ଶ؅ཧ

    ᶅ +BWB1FSTJTUFODF2VFSZ-BOHVBHF +12-  ᶆ ϦϨʔγϣϯͱ/ ໰୊ରࡦ ᶇ ࠓճ͸঺հͰ͖ͳ͔ͬͨػೳ ᶈ +1"͸ʮ࢖͑Δʯͷ͔ʁ 12
  13. (C) CASAREAL, Inc. All rights reserved. +1"ͷΞʔΩςΫνϟ 13 &OUJUZ .BOBHFS

    ӬଓԽίϯςΩετ &OUJUZ &OUJUZ &OUJUZ ΫϥΠΞϯτ
 ϓϩάϥϜ DB &OUJUZ &OUJUZ .BOBHFS 'BDUPSZ ੜ੒
  14. (C) CASAREAL, Inc. All rights reserved. ΤϯςΟςΟ ▸ جຊతʹςʔϒϧͱ
 ରͰ࡞Δ

    ▸ ʮ4&-&$5จͱରʯ
 Ͱ͸ͳ͍ʂ ▸ ओΩʔϑΟʔϧυඞਢ 14 @Entity public class Product { @Id private Integer id; private String name; // setter/getter }
  15. (C) CASAREAL, Inc. All rights reserved. &OUJUZ.BOBHFS ▸ ΤϯςΟςΟͷʮঢ়ଶʯΛૢ࡞͢Δ૭ޱ ▸

    ʮ$36%ૢ࡞ͷ૭ޱʯͰ͸ͳ͍ͷͰ஫ҙʂ ▸ ݕࡧ݁Ռ͸ӬଓԽίϯςΩετʢޙड़ʣʹอଘ ▸ Πϯελϯε͸
 τϥϯβΫγϣϯ୯Ґ 15
  16. (C) CASAREAL, Inc. All rights reserved. &OUJUZ.BOBHFS'BDUPSZ ▸ &OUJUZ.BOBHFSΛੜ੒͢Δ ▸

    Πϯεϯλϯε͸ΞϓϦέʔγϣϯͰͭͷΈ
 ʢʹγϯάϧτϯʣ 16
  17. (C) CASAREAL, Inc. All rights reserved. ӬଓԽίϯςΩετ ▸ ΤϯςΟςΟͷΩϟογϡͷΑ͏ͳ΋ͷ ▸

    ΤϯςΟςΟ͕ӬଓԽίϯςΩετʹؚ·Ε͍ͯΔ͔ Ͳ͏͔͕ඇৗʹॏཁ ▸ τϥϯβΫγϣϯ୯ҐͰ
 ੜ੒ɾഁغ͞ΕΔ 17
  18. (C) CASAREAL, Inc. All rights reserved. ΤϯςΟςΟͷʮঢ়ଶʯ 18 ঢ়ଶ આ໌

    NEW new͞Εͨ͹͔Γ MANAGED ӬଓԽίϯςΩετͰ؅ཧ͞Ε͍ͯΔ DETACHED ӬଓԽίϯςΩετ͔Β෼཭͞Ε͍ͯΔ REMOVED ࡟আ͕༧໿͞Ε͍ͯΔ
  19. (C) CASAREAL, Inc. All rights reserved. &OUJUZ.BOBHFSͷϝιου 19 ϝιου આ໌

    find() ओΩʔݕࡧ persist() 1݅ͷӬଓԽ remove() 1݅ͷ࡟আ merge() ӬଓԽίϯςΩετ؅ཧԼʹ͢Δ detach() ӬଓԽίϯςΩετ؅ཧ֎ʹ͢Δ flush() มߋΛDB΁൓ө clear() ӬଓԽίϯςΩετΛΫϦΞ refresh() ΤϯςΟςΟͷ಺༰ΛDB࠷৽ʹ্ॻ͖
  20. (C) CASAREAL, Inc. All rights reserved. ˒ॏཁ˒ΤϯςΟςΟͷঢ়ଶભҠ 20 ӬଓԽίϯςΩετ ."/"(&%

    ঢ়ଶ 3&.07&% ঢ়ଶ /&8 ঢ়ଶ %&5"$)&% ঢ়ଶ persist() detach()
 clear() merge() remove() flush() flush() refresh() find()
 JPQL detach()
 clear()
  21. (C) CASAREAL, Inc. All rights reserved. ओΩʔݕࡧ 21 EntityManager em

    = …; // ୈ1Ҿ਺ʹΤϯςΟςΟΫϥεɺୈ2Ҿ਺ʹओΩʔ஋ Product product = em.find(Product.class, 1); ▸ جຊతʹશϑΟʔϧυʹ૬౰͢Δྻ͕ݕࡧ͞ΕΔ select product0_.id as id1_5_0_, product0_.category_id as category4_5_0_, product0_.name as name2_5_0_, product0_.price as price3_5_0_, product0_.vendor_id as vendor_i5_5_0_ from product product0_ where product0_.id=? ͜ΜͳSQL͕
 ൃߦ͞ΕΔ
  22. (C) CASAREAL, Inc. All rights reserved. ௥Ճ 22 Product product

    = new Product(“Ε͍ͧ͏͜”, 100000L); em.persist(product); ▸ جຊతʹશϑΟʔϧυ͕*/4&35͞ΕΔ ▸ */4&35͠ͳ͍ϑΟʔϧυʹ͸!5SBOTJFOUΛ෇Ճ͢Δ insert into product (category_id, name, price, vendor_id, id) values (?, ?, ?, ?, ?)
  23. (C) CASAREAL, Inc. All rights reserved. ߋ৽ 23 // find()Ͱݕࡧ͢ΔͱMANAGEDঢ়ଶ

    Product product = em.find(Product.class, 1); // ஋ͷߋ৽ product.setName("ߋ৽ޙͷ໊લ"); // ߋ৽ͷ൓ө(ίϛοτͰ΋OK) em.flush(); ▸ ."/"(&%ঢ়ଶͷΤϯςΟςΟʹTFUUFSͰ஋Λ ߋ৽ˠ൓ө
  24. (C) CASAREAL, Inc. All rights reserved. ߋ৽ 24 select …

    from product product0_ where product0_.id=? binding parameter [1] as [INTEGER] - [1] update product set category_id=?, name=?, price=?, vendor_id=? where id=? binding parameter [1] as [INTEGER] - [1] binding parameter [2] as [VARCHAR] - [ߋ৽ޙͷ໊લ] binding parameter [3] as [BIGINT] - [100000] binding parameter [4] as [INTEGER] - [1] binding parameter [5] as [INTEGER] - [1]
  25. (C) CASAREAL, Inc. All rights reserved. NFSHF ʹΑΔߋ৽ 25 Product

    product = new Product(); product.setId(1); product.setName(“ߋ৽ޙͷ໊લ"); // merge()Ͱ΋ߋ৽Ͱ͖Δ em.merge(product); em.flush(); ▸ OFXͨ͠ΤϯςΟςΟΛNFSHF ͢Δ
  26. (C) CASAREAL, Inc. All rights reserved. NFSHF ʹΑΔߋ৽ 26 select

    … from product product0_ where product0_.id=? binding parameter [1] as [INTEGER] - [1] update product set category_id=?, name=?, price=?, vendor_id=? where id=? binding parameter [1] as [INTEGER] - [null] binding parameter [2] as [VARCHAR] - [ߋ৽ޙͷ໊લ] binding parameter [3] as [BIGINT] - [null] binding parameter [4] as [INTEGER] - [null] binding parameter [5] as [INTEGER] - [1] ▸ 4&-&$5จʴ61%"5&จ͕ൃߦ͞ΕΔ
  27. (C) CASAREAL, Inc. All rights reserved. NFSHF ͷམͱ݀͠ ▸ Ҿ਺ΤϯςΟςΟͷίϐʔ͕࡞ΒΕɺͦΕ͕໭

    Γ஋͔ͭ."/"(&%ঢ়ଶʹͳΔ ▸ Ҿ਺ࣗମ͸."/"(&%ঢ়ଶʹͳΒͳ͍ͷͰ஫ҙ 27 Product mergedProduct = em.merge(product); // ໭Γ஋͸MANAGEDঢ়ଶ assertTrue(em.contains(mergedProduct)); // Ҿ਺ͷঢ়ଶ͸มΘΒͳ͍ assertFalse(em.contains(product));
  28. (C) CASAREAL, Inc. All rights reserved. ࡟আ 28 // find()Ͱݕࡧ͢ΔͱMANAGEDঢ়ଶ

    Product product = em.find(Product.class, 30); // REMOVEDঢ়ଶʹ͢Δ em.remove(product); // ߋ৽ͷ൓ө(ίϛοτͰ΋OK) em.flush(); ▸ ."/"(&%ঢ়ଶͷΤϯςΟςΟΛSFNPWF ͢Δ
  29. (C) CASAREAL, Inc. All rights reserved. ࡟আ 29 select …

    from product product0_ where product0_.id=? binding parameter [1] as [INTEGER] - [30] delete from product where id=? binding parameter [1] as [INTEGER] - [30]
  30. (C) CASAREAL, Inc. All rights reserved. ࡟আͷΩϟϯηϧ 30 // find()Ͱݕࡧ͢ΔͱMANAGEDঢ়ଶ

    Product product = em.find(Product.class, 30); // REMOVEDঢ়ଶʹ͢Δ em.remove(product); // DETACHEDঢ়ଶʹ͢Δ em.detach(product); // DETACHEDঢ়ଶͳͷͰDBʹ൓ө͞Εͳ͍ em.flush(); ▸ EFUBDI ·ͨ͸DMFBS Ͱ%&5"$)&%ঢ়ଶʹ͢Δ
  31. (C) CASAREAL, Inc. All rights reserved. ·ͱΊ ▸ ΤϯςΟςΟͷʮঢ়ଶʯʹ஫ҙ ▸

    pOE ͰओΩʔݕࡧ ▸ QFSTJTU Ͱ௥Ճ ▸ ߋ৽͸pOE  TFUUFSͰߋ৽ ▸ SFNPWF Ͱ࡟আ 31
  32. (C) CASAREAL, Inc. All rights reserved. ᶃ +1"ͱ͸ʁ ᶄ +1"ΤϯςΟςΟͷঢ়ଶ؅ཧ

    ᶅ +BWB1FSTJTUFODF2VFSZ-BOHVBHF +12-  ᶆ ϦϨʔγϣϯͱ/ ໰୊ରࡦ ᶇ ࠓճ͸঺հͰ͖ͳ͔ͬͨػೳ ᶈ +1"͸ʮ࢖͑Δʯͷ͔ʁ 32
  33. (C) CASAREAL, Inc. All rights reserved. +12-ͱ͸ʁ ▸ 42-ϥΠΫͳจ๏Ͱ4&-&$561%"5&%&-&5& Λهड़͢Δ

    ▸ */4&35͸ແ͍ ▸ %#੡඼ʹґଘ͠ͳ͍ΫΤϦ͕هड़Մೳ ▸ %#ݻ༗ػೳʹ͍ͭͯ͸ޙड़ 33
  34. (C) CASAREAL, Inc. All rights reserved. جຊతͳ࢖͍ํ 34 TypedQuery<Product> query

    = em.createQuery( "SELECT p FROM Product p WHERE p.id = :id", Product.class); query.setParameter("id", 1); Product product = query.getSingleResult(); TypedQuery<Product> query = em.createQuery( "SELECT p FROM Product p WHERE p.id <= :maxId" + " ORDER BY p.id", Product.class); query.setParameter("maxId", 5); List<Product> list = query.getResultList(); ▸ ୯Ұݕࡧ ▸ ෳ਺ݕࡧ
  35. (C) CASAREAL, Inc. All rights reserved. ࣮ߦ͢Δͱ42-ʹ຋༁͞ΕΔ 35 select product0_.id

    as id1_5_, product0_.category_id as category4_5_, product0_.name as name2_5_, product0_.price as price3_5_, product0_.vendor_id as vendor_i5_5_ from product product0_ where product0_.id=? ▸ ͲΜͳ42-͕ൃߦ͞ΕΔ͔͸+1"࢓༷Ͱະఆٛ
 ʹ׬શʹ࣮૷ґଘʢԼه͸)JCFSOBUFͷྫʣ
  36. (C) CASAREAL, Inc. All rights reserved. ͦͷଞͷ+12-Ͱग़དྷΔ͜ͱ ▸ ݁߹ʢ*//&3+0*/ɺ-&'5065&3+0*/ɻৄࡉ͸ޙ ड़ʣ

    ▸ #&58&&/ɺ*/ɺ-*,&ɺ&9*454ɺ"--ɺ"/:ɺ $"4&ɺ(3061#:ɺ)"7*/( ▸ ίϯετϥΫλࣜ ▸ ෭໰߹ͤʢ8)&3&۟ͱ)"7*/(۟ͰͷΈʣ ▸ ؔ਺͍Ζ͍Ζʢूܭɺจࣈྻɺ%#ݻ༗ؔ਺ͳͲʣ 36
  37. (C) CASAREAL, Inc. All rights reserved. +12-Ͱग़དྷͳ͍͜ͱ ▸ */4&35 ▸

    ू߹ԋࢉʢ6/*0/ɺ6/*0/"--ɺ */5&34&$5ɺ&9$&15ʣ ▸ '30.۟Ͱͷ෭໰߹ͤ 37
  38. (C) CASAREAL, Inc. All rights reserved. ·ͱΊ ▸ 42-ϥΠΫͳจ๏Ͱ%#ʹґଘ͠ͳ͍ΫΤϦΛه ड़Մೳ

    ▸ Ͱ͖Δ͜ͱɾͰ͖ͳ͍͜ͱΛ͔ͬ͠Γҙࣝ͢΂ ͠ 38
  39. (C) CASAREAL, Inc. All rights reserved. ᶃ +1"ͱ͸ʁ ᶄ +1"ΤϯςΟςΟͷঢ়ଶ؅ཧ

    ᶅ +BWB1FSTJTUFODF2VFSZ-BOHVBHF +12-  ᶆ ϦϨʔγϣϯͱ/ ໰୊ରࡦ ᶇ ࠓճ͸঺հͰ͖ͳ͔ͬͨػೳ ᶈ +1"͸ʮ࢖͑Δʯͷ͔ʁ 39
  40. (C) CASAREAL, Inc. All rights reserved. ϦϨʔγϣϯΛදݱ͢Δ ▸ !0OF5P0OF ▸

    !0OF5P.BOZ ▸ !.BOZ5P0OF ▸ !.BOZ5P.BOZ 40 @Entity public class Product { … @ManyToOne @JoinColumn(name="vendor_id") private Vendor vendor; } @Entity public class Vendor { … }
  41. (C) CASAREAL, Inc. All rights reserved. ϑΣονͱ͸ ▸ ͋ΔΤϯςΟςΟΛಡΈࠐΜͩ࣌ɺϦϨʔγϣϯઌ ͷΤϯςΟςΟΛ͍ͭಡΈࠐΉ͔

    ᶃ &"(&3ϑΣονɿଈ࣌ಡΈࠐΈ ▸ ಉ࣌ʹಡΈࠐΉʢ)JCFSOBUFͩͱ+0*/ɺ&DMJQTF-JOLͩͱ 4&-&$5จ͕ෳ਺ಉ࣌ʹൃߦʣ ᶄ -";:ϑΣονɿ஗ԆಡΈࠐΈ ▸ ඞཁʹͳͬͨ࣌ʢHFUUFS͕ݺ͹Εͨ࣌ʣʹಡΈࠐΉ 41
  42. (C) CASAREAL, Inc. All rights reserved. -";:ϑΣονͷྫ 42 select (ྻলུ)

    from product product0_ where product0_.id=? select (ྻলུ) from vendor vendor0_ where vendor0_.id=? @Entity public class Product { @ManyToOne(fetch = FetchType.LAZY) private Vendor vendor; } Product p = em.find(Product.class, 1); Vendor v = p.getVendor(); String n = v.getName() // ͜͜Ͱ΋SELECT 2ճ SELECT
  43. (C) CASAREAL, Inc. All rights reserved. -";:ϑΣονͷ஫ҙ఺ ▸ ӬଓԽίϯςΩετഁغޙʢ㲈τϥϯβΫγϣϯ ऴྃޙʣʹϑΣον͢Δͱྫ֎͕ൃੜ͢Δ

    43 em.getTransaction().begin(); Product p = em.find(Product.class, 1); em.getTransaction().rollback(); Vendor v = p.getVendor(); String n = v.getName(); // ͜͜Ͱྫ֎ൃੜ
  44. (C) CASAREAL, Inc. All rights reserved. &"(&3ϑΣονͷྫ 44 @Entity public

    class Product { @ManyToOne(fetch = FetchType.EAGER) private Vendor vendor; } Product p = em.find(Product.class, 1); Vendor v = p.getVendor(); // طʹಡΈࠐΈࡁΈ select (ྻলུ) from product product0_ left outer join vendor vendor2_ on product0_.vendor_id=vendor2_.id where product0_.id=? 1ճͷΈ SELECT
  45. (C) CASAREAL, Inc. All rights reserved. ϑΣον͸جຊ-";:ʂ ▸ &"(&3ʹ͢Δͱෆཁͳσʔλ·ͰಡΈࠐΉ͔Β ▸

    !0OF5P.BOZͰେྔͷσʔλΛಡΈࠐΉͱ͔ڪා
 ʢʹ/ ໰୊ʣ ▸ -";:͔Β&"(&3ʹಈతʹมߋ͍ͨ͠৔߹͸ɺ +12-ͷ+0*/'&5$)จΛར༻͢Δ 45
  46. (C) CASAREAL, Inc. All rights reserved. / ໰୊͕ى͜Δྫ 46 //

    order_summary΁ͷSELECT͕ൃߦ͞ΕΔʢ1ճʣ List<OrderSummary> list = em.createQuery( "SELECT os FROM OrderSummary os",OrderSummary.class) .getResultList(); for (OrderSummary os : list) { // ·ͩorder_detail͸ಡΈࠐ·Ε͍ͯͳ͍ System.out.println(os); for (OrderDetail od : os.getOrderDetailList()) { // ͜͜Ͱorder_detail΁ͷSELECT͕ൃߦ͞ΕΔ(Nճ) System.out.println(od); } }
  47. (C) CASAREAL, Inc. All rights reserved. +0*/'&5$)จͰղܾʂʁ ▸ -";:ʹͳ͍ͬͯΔϦϨʔγϣϯΛಈతʹ&"(&3 ʹมߋͯ͘͠ΕΔ

    47 // order_summary΁ͷSELECT͕ൃߦ͞ΕΔʢ1ճʣ List<OrderSummary> list = em.createQuery( "SELECT os FROM OrderSummary os" + " JOIN FETCH os.orderDetailList" + , OrderSummary.class) .getResultList();
  48. (C) CASAREAL, Inc. All rights reserved. +0*/'&5$)จͰղܾʂʁ 48 select ordersumma0_.id

    as id1_3_0_, orderdetai1_.id as id1_2_1_, ordersumma0_.customer_id as customer3_3_0_, ordersumma0_.order_timestamp as order_ti2_3_0_, orderdetai1_.amount as amount2_2_1_, orderdetai1_.product_id as product_3_2_1_, orderdetai1_.summary_id as summary_4_2_0__, orderdetai1_.id as id1_2_0__ from order_summary ordersumma0_ inner join order_detail orderdetai1_ on ordersumma0_.id=orderdetai1_.summary_id where ordersumma0_.id=? JOINͯ͠
 શྻऔಘ
  49. (C) CASAREAL, Inc. All rights reserved. දࣔ͢Δͱɾɾɾ 49 OrderSummary{id=1, orderTimestamp=2017-04-01T10:00}

    OrderDetail{id=1, amount=2} OrderDetail{id=2, amount=2} OrderDetail{id=3, amount=2} OrderSummary{id=1, orderTimestamp=2017-04-01T10:00} OrderDetail{id=1, amount=2} OrderDetail{id=2, amount=2} OrderDetail{id=3, amount=2} OrderSummary{id=1, orderTimestamp=2017-04-01T10:00} OrderDetail{id=1, amount=2} OrderDetail{id=2, amount=2} OrderDetail{id=3, amount=2} OrderSummary{id=2, orderTimestamp=2017-04-01T10:00} OrderDetail{id=4, amount=2} OrderDetail{id=5, amount=2} ɾɾɾ ಉ͡σʔλ͕
 Կճ΋ʂʁ
  50. (C) CASAREAL, Inc. All rights reserved. +0*/'&5$) %*45*/$5Ͱղܾʂ 50 //

    order_summary΁ͷSELECT͕ൃߦ͞ΕΔʢ1ճʣ List<OrderSummary> list = em.createQuery( "SELECT DISTINCT os FROM OrderSummary os" + " JOIN FETCH os.orderDetailList" + , OrderSummary.class) .getResultList();
  51. (C) CASAREAL, Inc. All rights reserved. +0*/'&5$) %*45*/$5Ͱղܾʂ 51 select

    distinct ordersumma0_.id as id1_3_0_, orderdetai1_.id as id1_2_1_, ordersumma0_.customer_id as customer3_3_0_, ordersumma0_.order_timestamp as order_ti2_3_0_, orderdetai1_.amount as amount2_2_1_, orderdetai1_.product_id as product_3_2_1_, orderdetai1_.summary_id as summary_4_2_0__, orderdetai1_.id as id1_2_0__ from order_summary ordersumma0_ inner join order_detail orderdetai1_ on ordersumma0_.id=orderdetai1_.summary_id where ordersumma0_.id=? distinct͕෇͕͘
 SQLͷ݁Ռ͸
 ͜ͷ৔߹͸ಉ͡
  52. (C) CASAREAL, Inc. All rights reserved. දࣔ͢Δͱɾɾɾ 52 OrderSummary{id=1, orderTimestamp=2017-04-01T10:00}

    OrderDetail{id=3, amount=2} OrderDetail{id=1, amount=2} OrderDetail{id=2, amount=2} OrderSummary{id=2, orderTimestamp=2017-04-01T10:00} OrderDetail{id=5, amount=2} OrderDetail{id=6, amount=2} OrderDetail{id=4, amount=2} OrderSummary{id=9, orderTimestamp=2017-04-01T10:00} OrderSummary{id=7, orderTimestamp=2017-04-01T10:00} OrderSummary{id=6, orderTimestamp=2017-04-01T10:00} OrderSummary{id=5, orderTimestamp=2017-04-01T10:00} OrderSummary{id=4, orderTimestamp=2017-04-01T10:00} OrderSummary{id=3, orderTimestamp=2017-04-01T10:00} OrderSummary{id=8, orderTimestamp=2017-04-01T10:00} OrderSummary{id=10, orderTimestamp=2017-04-01T10:00} σʔλͷॏෳ͕
 ແ͘ͳͬͨʂ
  53. (C) CASAREAL, Inc. All rights reserved. +12-ͷ%*45*/$5۟ ▸ 42-ͷ%*45*/$5۟ʴ-JTUͷॏෳ΋࡟আ͢Δ 53

  54. (C) CASAREAL, Inc. All rights reserved. ·ͱΊ ▸ 'FUDI5ZQF͸-";:Λࢦఆ͠Α͏ʂ ▸

    +0*/'&5$)จ %*45*/$5۟Ͱ/ ໰୊Λղ ܾͰ͖Δʂ 54
  55. (C) CASAREAL, Inc. All rights reserved. ᶃ +1"ͱ͸ʁ ᶄ +1"ΤϯςΟςΟͷঢ়ଶ؅ཧ

    ᶅ +BWB1FSTJTUFODF2VFSZ-BOHVBHF +12-  ᶆ ϦϨʔγϣϯͱ/ ໰୊ରࡦ ᶇ ࠓճ͸঺հͰ͖ͳ͔ͬͨػೳ ᶈ +1"͸ʮ࢖͑Δʯͷ͔ʁ 55
  56. (C) CASAREAL, Inc. All rights reserved. ঺հͰ͖ͳ͔ͬͨػೳ ▸ %#੡඼ݻ༗ػೳͷར༻ ▸

    ωΠςΟϒ42-΍ΠϯσοΫεͳͲ ▸ ਖ਼௚ɺ࢖͍ͮΒ͍ ▸ 4QSJOH%BUB+1" ▸ ศརػೳຬࡌ ▸ ࣮͸+BWB&& $%* ؀ڥͰ΋࢖͑Δ 56
  57. (C) CASAREAL, Inc. All rights reserved. ᶃ +1"ͱ͸ʁ ᶄ +1"ΤϯςΟςΟͷঢ়ଶ؅ཧ

    ᶅ +BWB1FSTJTUFODF2VFSZ-BOHVBHF +12-  ᶆ ϦϨʔγϣϯͱ/ ໰୊ରࡦ ᶇ ࠓճ͸঺հͰ͖ͳ͔ͬͨػೳ ᶈ +1"͸ʮ࢖͑Δʯͷ͔ʁ 57
  58. (C) CASAREAL, Inc. All rights reserved. +1"͸ʮ࢖͑Δʯ͔ʁ ▸ ʮ࢖͑Δɻͨͩ͠ਖ਼͍͠஌͕ࣝඞཁɺ͔ͭγνϡ ΤʔγϣϯΛબͿʯͱ͍͏ͷ͕ݸਓతͳҙݟͰ

    ͢ 58
  59. (C) CASAREAL, Inc. All rights reserved. +1"Λ࢖͍͍ͬͯ৚݅ ᶃ %#Λ৽نʹઃܭͰ͖Δ ᶄ

    ू߹ԋࢉ΍'30.۟Ͱͷ෭໰߹ͤͳͲɺ
 ෳࡶͳ42-͸ཁ݅తʹগͳ͍ ᶅ ʮύʔϑΣΫτ+BWB&&ʯΛಡഁͨ͠ਓ͕
 ϓϩδΣΫτʹਓҎ্͍Δ 59 ͭͰ΋౰ͯ͸·Βͳ͍߲໨͕͋Ε͹ɺ ଞͷ03ϚούʔΛ࢖ͬͨํ͕͍͍͔΋
  60. (C) CASAREAL, Inc. All rights reserved. ඞಡॻ੶ 60 ▸ ύʔϑΣΫτ+BWB&&

    ▸ +1"ͷষΛಡഁ͍ͯͩ͘͠͞
  61. (C) CASAREAL, Inc. All rights reserved. ඞಡࢿྉ ▸ ͸·Δʂ+1"ʢॳֶऀ޲͚ϥΠτ൛ʣ !TVLF@NBTB

     ▸ IUUQTXXXTMJEFTIBSFOFUNBTBUPTIJUBEBKQB ▸ ͸·Δʂ+1" !NBLJOH͞Μ  ▸ IUUQTXXXTMJEFTIBSFOFUNBLJOHYKQB ▸ +1"ͷಉ࣮࣌ߦ੍ޚͱϩοΫ !TVLF@NBTB  ▸ IUUQTXXXTMJEFTIBSFOFUNBTBUPTIJUBEBKQBDDDSKKVH DDD ▸ !PQFOHM@͞Μͷ2JJUBهࣄҰ࿈ ▸ IUUQRJJUBDPNPQFOHMJUFNTGGBFDC 61
  62. (C) CASAREAL, Inc. All rights reserved. ϦϑΝϨϯε ▸ )JCFSOBUF6TFS(VJEF ▸

    IUUQEPDTKCPTTPSHIJCFSOBUFPSN VTFSHVJEFIUNM@TJOHMF )JCFSOBUF@6TFS@(VJEFIUNM ▸ +1" +43  ▸ IUUQTKDQPSHBCPVU+BWBDPNNVOJUZQSPDFTT pOBMKTSJOEFYIUNM 62
  63. (C) CASAREAL, Inc. All rights reserved. &OKPZ+1" ▸ ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ 63