{"id":19191,"date":"2019-10-16T16:25:26","date_gmt":"2019-10-16T07:25:26","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=19191"},"modified":"2019-10-16T16:25:26","modified_gmt":"2019-10-16T07:25:26","slug":"room-%ec%bb%b4%ed%8c%8c%ec%9d%bc%eb%9f%ac-%ec%98%b5%ec%85%98-%ec%a4%91-room-expandprojection-%ec%82%ac%ec%9a%a9%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=19191","title":{"rendered":"Room \ucef4\ud30c\uc77c\ub7ec \uc635\uc158 \uc911 room.expandProjection \uc0ac\uc6a9\ud558\uae30"},"content":{"rendered":"<h1>room.expandProjection \uc635\uc158<\/h1>\n<p>2019\ub144 10\uc6d4 9\uc77c Room 2.2.0 stable \ubc84\uc804\uc774 \ucd9c\uc2dc \ub428\uc5d0 \ub530\ub77c\u00a0 <strong>room.expandProjection<\/strong> \uc635\uc158\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\uac8c \ub418\uc5c8\ub2e4.<\/p>\n<h3><strong>room.expandProjection<\/strong> \uc635\uc158 \uc124\uc815\ud558\uae30<\/h3>\n<pre class=\"lang:java decode:true\">android {\r\n    ...\r\n    defaultConfig {\r\n        ...\r\n        javaCompileOptions {\r\n            annotationProcessorOptions {\r\n                arguments = [\"room.expandProjection\":\"true\"]\r\n            }\r\n        }\r\n    }\r\n}<\/pre>\n<p>\ub9b4\ub9ac\uc988 \ub178\ud2b8 \ubc0f \uacf5\uc2dd\ubb38\uc11c\uc5d0 \ub2e4\uc74c\uacfc \uac19\uc740 \ub0b4\uc6a9\uc774 \uc788\ub2e4.<\/p>\n<table style=\"border-collapse: collapse; width: 100%;\">\n<tbody>\n<tr>\n<td style=\"width: 100%; border-color: #000000; border-style: solid;\">room.expandProjection: Configures Room to rewrite queries such that their top star projection is expanded to only contain the columns defined in the DAO method return type.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\uc2a4\ud0c0(*) \ud504\ub85c\uc81d\uc158\uc744 \uc0ac\uc6a9\ud558\ub294 DAO \uba54\uc18c\ub4dc\uc5d0 \ub300\ud574 \ud574\ub2f9 \uba54\uc18c\ub4dc\uac00 \uac00\uc9c4 \uceec\ub7fc\ub9cc \uac00\uc838\uc624\uae30 \uc704\ud574 \ucffc\ub9ac\ub97c \uc7ac\uc791\uc131 \ud55c\ub2e4\ub294 \ub0b4\uc6a9\uc774\ub2e4.<\/p>\n<p>\uc608\uc81c\ub97c \ud1b5\ud574 \uc54c\uc544\ubcf4\uc790.<\/p>\n<p>\ub2e4\uc74c\uacfc \uac19\uc740 POJO \ud074\ub798\uc2a4\uac00 \uc788\ub2e4\uace0 \uac00\uc815\ud55c\ub2e4.<\/p>\n<pre class=\"lang:java decode:true\">@Entity\r\npublic class User {\r\n    @PrimaryKey(autoGenerate = true)\r\n    public int id;\r\n    public String name;\r\n    public int age;\r\n\r\n    public User(String name){\r\n        this.name = name;\r\n    }\r\n}<\/pre>\n<pre class=\"lang:java decode:true \">public class UserName {\r\n    public String name;\r\n}<\/pre>\n<p>User \uc5d4\ud130\ud2f0 \ud074\ub798\uc2a4\uac00 \uc788\uace0, User \ud074\ub798\uc2a4\uac00 \uac00\uc9c0\uace0 \uc788\ub294 \ud544\ub4dc\uc758 \uc77c\ubd80\ub9cc\uc744 \uac00\uc9c0\uace0 \uc788\ub2e4. \uc774\uc81c DAO \uc778\ud130\ud398\uc774\uc2a4\ub97c \uc0b4\ud3b4\ubcf4\uc790.<\/p>\n<pre class=\"lang:java decode:true\">@Dao\r\npublic interface UserRepository {\r\n    @Query(\"SELECT * FROM User\")\r\n    LiveData&lt;List&lt;UserName&gt;&gt; loadUserNames();\r\n}\r\n<\/pre>\n<p>User \ud14c\uc774\ube14\uc758 \ubaa8\ub4e0 \ub808\ucf54\ub4dc\ub97c \uac00\uc838\uc624\uc9c0\ub9cc, UserName\uc740 name\uceec\ub7fc\ub9cc \uac00\uc9c0\uace0 \uc788\ub2e4.<\/p>\n<p>room.expandProjection \uc635\uc158\uc774 \ube44\ud65c\uc131\ud654 \ub418\uc5b4\uc788\uc744 \ub54c Room \uc5b4\ub178\ud14c\uc774\uc158 \ud504\ub85c\uc138\uc11c\uc5d0 \uc758\ud574 \uc0dd\uc131\ub418\ub294 UserRepository_Impl.java\uc758 \ucf54\ub4dc\ub97c \ud655\uc778\ud558\uba74 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"lang:java decode:true\">@Override\r\n  public LiveData&lt;List&lt;UserName&gt;&gt; loadUserNames() {\r\n    final String _sql = \"SELECT * FROM User\";\r\n    ...\r\n  }<\/pre>\n<p>\uc774\ubc88\uc5d4 room.expandProjection\uc744 \ud65c\uc131\ud654 \ud574\ubcf4\uc790.<\/p>\n<pre class=\"lang:java decode:true\">@Override\r\n  public LiveData&lt;List&lt;UserName&gt;&gt; loadUserNames() {\r\n    final String _sql = \"SELECT `name` FROM User\";\r\n    ...\r\n  }<\/pre>\n<p>UserName\uc774 \uac00\uc9c0\uace0 \uc788\ub294 \ud544\ub4dc\ub4e4\ub85c \ud504\ub85c\uc81d\uc158\uc774 \ubcc0\uacbd\ub418\uace0 \ucffc\ub9ac\uac00 \uc7ac\uc791\uc131\ub41c\uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\ub2e4.<\/p>\n<h2>TL;DR<\/h2>\n<p><strong>room.expandProjection\u00a0<\/strong>\uc0ac\uc6a9\uc2dc \ucffc\ub9ac\uc758 \ube44\uc6a9\uc744 \uc904\uc5ec\uc8fc\uace0, \uadfc\ubcf8\uc801\uc73c\ub85c CURSOR_MISMATCH \uacbd\uace0\ub97c \uc81c\uac70\ud574\uc904 \uc218 \uc788\ub2e4.\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>room.expandProjection \uc635\uc158 2019\ub144 10\uc6d4 9\uc77c Room 2.2.0 stable \ubc84\uc804\uc774 \ucd9c\uc2dc \ub428\uc5d0 \ub530\ub77c\u00a0 room.expandProjection \uc635\uc158\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\uac8c \ub418\uc5c8\ub2e4. room.expandProjection \uc635\uc158 \uc124\uc815\ud558\uae30 android { &#8230; defaultConfig { &#8230; javaCompileOptions { annotationProcessorOptions { arguments = [&#8220;room.expandProjection&#8221;:&#8221;true&#8221;] } } } } \ub9b4\ub9ac\uc988 \ub178\ud2b8 \ubc0f \uacf5\uc2dd\ubb38\uc11c\uc5d0 \ub2e4\uc74c\uacfc \uac19\uc740 \ub0b4\uc6a9\uc774 \uc788\ub2e4. room.expandProjection: Configures Room to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[16],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/19191"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=19191"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/19191\/revisions"}],"predecessor-version":[{"id":19192,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/19191\/revisions\/19192"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=19191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=19191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=19191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}