{"id":187526,"date":"2013-07-23T12:58:03","date_gmt":"2013-07-23T08:58:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=187526"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=187526","title":{"rendered":"<span class=\"post_title\">\u041f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u0439 Orm \u043f\u043e\u0434 Android \u0441 \u043a\u0430\u043d\u0430\u0441\u0442\u043e\u0439 \u0438 \u0441\u0435\u043d\u044c\u043e\u0440\u0438\u0442\u0430\u043c\u0438, \u0427\u0430\u0441\u0442\u044c 2-\u0430\u044f<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u043a \u043c\u043e\u0435\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b \u043c\u0435\u043d\u044f \u0443\u0441\u0438\u043b\u0435\u043d\u043d\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 orm. \u041c\u043d\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435 \u0432 \u043d\u0435\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f (\u0433\u0434\u0435-\u0442\u043e \u043a\u043e\u0434 \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d; \u0433\u0434\u0435-\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0442\u0430\u043a\u0430\u044f, \u043a\u0430\u043a \u044f \u0445\u043e\u0442\u0435\u043b; \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438), \u043d\u043e \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0418 \u0442\u0430\u043a, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435: <a href=\"https:\/\/github.com\/UCASoft\/UcaOrm\">UcaOrm<\/a>!<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0443 \u0441 <b>orm<\/b> \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 <a href=\"http:\/\/habrahabr.ru\/post\/186078\/\">1-\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>):  <\/p>\n<pre><code class=\"java\">public class BaseEntity extends OrmEntity {          @Column(primaryKey = true, inherited = true)        private Long id; }   @Table(name = &quot;car_type&quot;, cashedList = true) public class CarType extends BaseEntity  {          @Column        private String code; }   @Table(rightJoinTo = {Truck.class}) public class Car extends BaseEntity {          @Column(name = &quot;car_type&quot;)        private CarType type;          @Column        private List&lt;Wheel&gt; wheels;          @Column(name = &quot;engine_power&quot;)        private int enginePower;          @Column(name = &quot;doors_count&quot;)        private int doorsCount; }   @Table public class Wheel extends BaseEntity {          @Column(name = &quot;car_id&quot;)        private Car car;          @Column        private String manufacturer; }   @Table(leftJoinTo = Car.class) public class Truck extends Car {          @Column(name = &quot;is_tipper&quot;)        private boolean isTipper; } <\/code><\/pre>\n<p>  <\/p>\n<h5>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/h5>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 (\u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u044f \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 <b>jar<\/b>, \u0430 \u043f\u043e\u043a\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0435\u0433\u043e \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432), \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c <b>Helper<\/b> \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 <b>OrmHelper<\/b>:  <\/p>\n<pre><code class=\"java\">public class DataBaseHelper extends OrmHelper {      public DataBaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {         super(context, name, factory, version);     }      @Override     protected void onCreate() {     }      @Override     protected void onUpgrade(int oldVersion, int newVersion) {     }      @Override     public void getDefaultValues(Class&lt;? extends OrmEntity&gt; entityClass, ArrayList&lt;String&gt; columns, ArrayList&lt;ContentValues&gt; valueList) {             } } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <b>getDefaultValues<\/b> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u0415\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430, \u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043d\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c <b>helper<\/b>. \u0414\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 <b>Application<\/b>:  <\/p>\n<pre><code class=\"java\">public class MyApp extends Application {      @Override     public void onCreate() {         super.onCreate();        try {             OrmFactory.SetHelper(DataBaseHelper.class, getApplicationContext());         } catch (Exception e) {             e.printStackTrace();         }     }      @Override     public void onTerminate() {         OrmFactory.ReleaseHelper();         super.onTerminate();     } } <\/code><\/pre>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0438\u043c\u044f \u0431\u0430\u0437\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u0437 <b>Label<\/b> \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0430 \u0432\u0435\u0440\u0441\u0438\u044f \u0431\u0443\u0434\u0435\u0442 <b>1<\/b>-\u043e\u0439. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <b>manifest<\/b> \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:  <\/p>\n<pre><code class=\"xml\">&lt;meta-data android:name=&quot;UO_DB_NAME&quot; android:value=&quot;Cars&quot; \/&gt; &lt;meta-data android:name=&quot;UO_DB_VERSION&quot; android:value=&quot;1&quot; \/&gt; <\/code><\/pre>\n<p>   <\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446<\/h5>\n<p>   \u0422\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <b>onCreate<\/b>, \u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <b>onUpdate<\/b>, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0435\u0449\u0435 \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 <b>orm<\/b>.<br \/>  \u0418 \u0442\u0430\u043a, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:  <\/p>\n<pre><code class=\"java\">protected void onCreate() {         try {             OrmUtils.CreateTable(CarType.class);             OrmUtils.CreateTable(Car.class);             OrmUtils.CreateTable(Wheel.class);             OrmUtils.CreateTable(Truck.class);         } catch (Exception e) {             e.printStackTrace();         }     } <\/code><\/pre>\n<p>   \u0418 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <b>CarType<\/b> \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438:  <\/p>\n<pre><code class=\"java\">public void getDefaultValues(Class&lt;? extends OrmEntity&gt; entityClass, ArrayList&lt;String&gt; columns, ArrayList&lt;ContentValues&gt; valueList) {         ContentValues values;         if (entityClass.equals(CarType.class)) {             values = new ContentValues();             values.put(columns.get(0), &quot;Passenger&quot;);             valueList.add(values);             values = new ContentValues();             values.put(columns.get(0), &quot;Truck&quot;);             valueList.add(values);         }       } <\/code><\/pre>\n<p>   \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f <b>getDefaultValues<\/b> \u0445\u0440\u043e\u043c\u0430\u0435\u0442.<\/p>\n<h5>\u041f\u0440\u043e\u0441\u0442\u0430\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0430<\/h5>\n<p>   \u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 <b>CarType<\/b> \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0442\u043e \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c \u0443\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0441 <b>Where<\/b>.<br \/>   \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0442\u0438\u043f\u0430 \u00ab<i>\u041b\u0435\u0433\u043a\u043e\u0432\u043e\u0439 \u0430\u0432\u0442\u043e\u043c\u043e\u0431\u0438\u043b\u044c<\/i>\u00bb. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0435 \u043d\u0430\u043c \u0442\u0438\u043f\u044b. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 <b>orm<\/b> \u0434\u043e\u043b\u0436\u043d\u044b \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 <b>OrmEntity<\/b>, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0435\u0433\u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c <b>getAllEntities<\/b>. \u0414\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <b>CarType<\/b>:  <\/p>\n<pre><code class=\"java\">public static List&lt;CarType&gt; getAllCarTypes(){         try {             return OrmEntity.getAllEntities(CarType.class);         } catch (Exception e) {             e.printStackTrace();         }         return null;     } <\/code><\/pre>\n<p>  <\/p>\n<h5>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439<\/h5>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Car:  <\/p>\n<pre><code class=\"java\">\tCar car = new Car(); \tcar.setType(CarType. getAllCarTypes().get(0)); \tcar.setEnginePower(116); \tcar.setDoorsCount(4); \tWheel whell = new Whell(); \twhell.setCar(car); \twhell.setManufacturer(&quot;Michrelli&quot;); \tcar.addWheel(whell); <\/code><\/pre>\n<p>   \u041a\u043e\u043d\u0435\u0447\u043d\u043e <b>whell.setCar<\/b> \u043b\u0443\u0447\u0448\u0435 \u0434\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 <b>addWheel<\/b> \u043a\u0430\u043a <b>whell.setCar(this)<\/b>, \u043d\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u0435\u0433\u043e \u0437\u0434\u0435\u0441\u044c \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438.<br \/>   \u0418 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0435\u0440\u0433\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <b>alter<\/b>:  <\/p>\n<pre><code class=\"java\">\tcar.alter(); <\/code><\/pre>\n<p>   \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440:  <\/p>\n<pre><code class=\"java\">\tcar.setEnginePower(120); \tcar.getWheels().get(0).setManufacturer(&quot;Pirlin&quot;); <\/code><\/pre>\n<p>  \u0418 \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c, <b>alter<\/b>:  <\/p>\n<pre><code class=\"java\">\tcar.alter(); <\/code><\/pre>\n<p>   \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u00ab<i>\u0413\u0440\u0443\u0437\u043e\u0432\u0438\u043a<\/i>\u00bb:<\/p>\n<pre><code class=\"java\">\tTruck truck = new Truck(); \ttruck.setType(CarType.getAllCarTypes().get(1)); \ttruck.setEnginePower(220); \ttruck.setDoorsCount(2); \tWheel whell = new Whell(); \twhell.setCar(truck); \twhell.setManufacturer(&quot;Michrelli&quot;); \ttruck.addWheel(whell); \ttruck.setTipper(true); \ttruck.alter(); <\/code><\/pre>\n<p>   \u041f\u0440\u0438\u0447\u0435\u043c \u043d\u0430\u043c \u043d\u0435 \u0432\u0430\u0436\u0435\u043d \u0442\u0438\u043f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0435\u0451 \u0438 \u043a\u0430\u043a <b>Car<\/b>, \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e \u0432 \u043d\u0435\u0439 \u043b\u0435\u0436\u0438\u0442.<\/p>\n<h5>\u0412\u044b\u0431\u043e\u0440\u043a\u0430<\/h5>\n<p>   \u0420\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432 <b>Car<\/b> \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430:  <\/p>\n<pre><code class=\"java\">public static List&lt;Car&gt; getAllCars() {         try {             return OrmEntity.getAllEntities(CarType.class, true);         } catch (Exception e) {             e.printStackTrace();         }         return null; }  public static List&lt;Car&gt; getCarsWithoutTrucks() {         try {             return OrmEntity.getAllEntities(CarType.class);         } catch (Exception e) {             e.printStackTrace();         }         return null; } <\/code><\/pre>\n<p>  \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043b\u0438\u0448\u044c \u0432 \u0432\u044b\u0437\u043e\u0432\u0435 <b>getAllEntities<\/b>, \u043e\u0434\u043d\u0430\u043a\u043e <b>getAllCars<\/b> \u0432\u0435\u0440\u043d\u0435\u0442 \u0434\u0432\u0435 \u0437\u0430\u043f\u0438\u0441\u0438, \u0430 <b>getCarsWithoutTrucks<\/b> \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0443: \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438, \u0438\u043b\u0438 \u0436\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u0435. <br \/>  \u0412\u0430\u0436\u043d\u043e, \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0441 \u0442\u0438\u043f\u043e\u043c <b>Passenger<\/b>. \u041f\u0440\u0438 \u0432\u044b\u0431\u043e\u0440\u043a\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 <b>CarType<\/b> \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u043a\u0430\u043a <b>CashedList<\/b>, \u043e\u0431\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 <b>Car<\/b> \u0431\u0443\u0434\u0443\u0442 \u0441\u0441\u044b\u043b\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <b>CarType<\/b>.<\/p>\n<h5>\u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0441 <b>Where<\/b><\/h5>\n<p>   \u041d\u0443, \u0438 \u0441\u0430\u043c\u043e\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0435!<br \/>   \u0412 <b>OrmEntity<\/b> \u0435\u0441\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <b>Where<\/b> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0414\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b \u043f\u0435\u0440\u0435\u043a\u0440\u043e\u0435\u043c \u0435\u0433\u043e \u0432 <b>Car<\/b>:  <\/p>\n<pre><code class=\"java\">    public static OrmWhere Where(){         return Where(Car.class);     } <\/code><\/pre>\n<p>   \u0418 \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u043c\u0430\u0448\u0438\u043d\u044b \u0441 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c\u044e <b>120<\/b> \u043b.\u0441:<\/p>\n<pre><code class=\"java\">\tList&lt;Car&gt; cars = Car.Where().Equels(&quot;engine_power&quot;, 120).Select(); <\/code><\/pre>\n<p>   \u0418\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u044b \u0441 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c\u044e <b>120<\/b> \u043b.\u0441. \u0438 \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0447\u0435\u0442\u044b\u0440\u0435 \u0434\u0432\u0435\u0440\u0438:<\/p>\n<pre><code class=\"java\">\tList&lt;Car&gt; cars = Car.Where().Equels(\u201cengine_power\u201d, 120).And().Equels(&quot;doors_count&quot;, 4).Select(); <\/code><\/pre>\n<p>   \u0418\u043b\u0438 \u043e\u0434\u043d\u0443 \u0438\u0437 \u043c\u0430\u0448\u0438\u043d \u0443 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0435\u0441\u0442\u044c \u043a\u043e\u043b\u0435\u0441\u043e \u043e\u0442 <b>Pirlin<\/b>:<\/p>\n<pre><code class=\"java\">\tCar car = Car.Where().FindChild(Wheel.class, new OrmWhere(Wheel.class).Equels(&quot;manufacturer&quot;, &quot;Pirlin&quot;)).SelectFirst(); <\/code><\/pre>\n<p>  \u0412\u044b\u0431\u043e\u0440\u043a\u0443 \u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438\u0437 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e\u043a\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f (\u0445\u043e\u0442\u044f <b>orm<\/b> \u0435\u0451 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438, \u0432\u0441\u0435 \u0447\u0442\u043e \u043d\u0430\u0434\u043e, \u044d\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043c\u0435\u0442\u043e\u0434 <b>Select<\/b> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c <b>includeLeftChild<\/b> \u0432 <b>OrmWhere<\/b>).<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p>   \u0412\u043e\u0442 \u043f\u043e\u0447\u0442\u0438 \u0438 \u0432\u0441\u0435 \u043d\u0430 \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u043c\u043e\u0439 <b>orm<\/b>. \u0421\u0435\u0439\u0447\u0430\u0441, \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0438\u0438, \u0447\u0442\u043e \u044f \u0435\u043c\u0443 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b \u0431\u044b \u2013 <b>0.1<\/b>. \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b, \u043e\u043d \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043c\u043e\u0435\u043c\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0442\u0430\u043a\u0438\u0435 \u043c\u0435\u043b\u043e\u0447\u0438, \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <b>Less<\/b> \u0438\u043b\u0438 <b>Great<\/b> \u0432 <b>OrmWhere<\/b> \u2013 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b. \u041d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 (\u0445\u043e\u0442\u044f \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u0442\u043e\u0442 \u0436\u0435 <b>CreateTable<\/b>). \u0418\u0437-\u0437\u0430 <b>left<\/b> \u0438 <b>right join<\/b> \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 <b>query<\/b> \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0434\u0435\u0440\u0433\u0430\u0442\u044c <b>rawQuery<\/b> \u0443 <b>SQLiteDatabase<\/b>, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b \u043d\u0430 \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0432\u043e\u0437\u0440\u043e\u0441\u043b\u0438 \u0441 <b>O(n-k)<\/b> (\u0433\u0434\u0435 <b>n<\/b> \u2013 \u043a\u043e\u043b-\u0432\u043e \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0430 <b>k<\/b> \u2013 \u043a\u043e\u043b-\u0432\u043e \u0443\u0436\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439) \u0434\u043e <b>O(n)<\/b>. \u041f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u0435\u0439\u0447\u0430\u0441 \u0442\u0438\u043f\u044b, \u044d\u0442\u043e: <b>Int<\/b>, <b>Long<\/b>, <b>Double<\/b>, <b>Date<\/b>, <b>String<\/b>, <b>Drawable<\/b> \u0438 <b>Document<\/b>.<br \/>   \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u0431\u044b\u043b \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044c, \u043d\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u043b\u044e\u0431\u044b\u043c \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c \u0438, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c \u043f\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044e <a href=\"https:\/\/github.com\/UCASoft\/UcaOrm\">UcaOrm<\/a>.    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/187526\/\"> http:\/\/habrahabr.ru\/post\/187526\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u043a \u043c\u043e\u0435\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b \u043c\u0435\u043d\u044f \u0443\u0441\u0438\u043b\u0435\u043d\u043d\u043e \u043f\u043e\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u0434 orm. \u041c\u043d\u0435 \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435 \u0432 \u043d\u0435\u043c \u043d\u0440\u0430\u0432\u0438\u0442\u044c\u0441\u044f (\u0433\u0434\u0435-\u0442\u043e \u043a\u043e\u0434 \u043d\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d; \u0433\u0434\u0435-\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0442\u0430\u043a\u0430\u044f, \u043a\u0430\u043a \u044f \u0445\u043e\u0442\u0435\u043b; \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438), \u043d\u043e \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043d\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0418 \u0442\u0430\u043a, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0439\u0442\u0435: <a href=\"https:\/\/github.com\/UCASoft\/UcaOrm\">UcaOrm<\/a>!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-187526","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/187526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187526"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/187526\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}