/
basic_mapping.pot
5925 lines (5192 loc) · 225 KB
/
basic_mapping.pot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# SOME DESCRIPTIVE TITLE.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
"POT-Creation-Date: 2010-07-20 21:02+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <kde-i18n-doc@kde.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: application/x-xml2pot; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#. Tag: title
#: basic_mapping.xml:31
#, no-c-format
msgid "Basic O/R Mapping"
msgstr ""
#. Tag: title
#: basic_mapping.xml:34
#, no-c-format
msgid "Mapping declaration"
msgstr ""
#. Tag: para
#: basic_mapping.xml:36
#, no-c-format
msgid "Object/relational mappings can be defined in three approaches:"
msgstr ""
#. Tag: para
#: basic_mapping.xml:41
#, no-c-format
msgid "using Java 5 annotations (via the Java Persistence 2 annotations)"
msgstr ""
#. Tag: para
#: basic_mapping.xml:46
#, no-c-format
msgid "using JPA 2 XML deployment descriptors (described in chapter XXX)"
msgstr ""
#. Tag: para
#: basic_mapping.xml:51
#, no-c-format
msgid "using the Hibernate legacy XML files approach known as hbm.xml"
msgstr ""
#. Tag: para
#: basic_mapping.xml:56
#, no-c-format
msgid "Annotations are split in two categories, the logical mapping annotations (describing the object model, the association between two entities etc.) and the physical mapping annotations (describing the physical schema, tables, columns, indexes, etc). We will mix annotations from both categories in the following code examples."
msgstr ""
#. Tag: para
#: basic_mapping.xml:62
#, no-c-format
msgid "JPA annotations are in the <literal>javax.persistence.*</literal> package. Hibernate specific extensions are in <literal>org.hibernate.annotations.*</literal>. You favorite IDE can auto-complete annotations and their attributes for you (even without a specific \"JPA\" plugin, since JPA annotations are plain Java 5 annotations)."
msgstr ""
#. Tag: para
#: basic_mapping.xml:69
#, no-c-format
msgid "Here is an example of mapping"
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:71
#, no-c-format
msgid ""
"package eg;\n"
"\n"
"@Entity \n"
"@Table(name=\"cats\") @Inheritance(strategy=SINGLE_TABLE)\n"
"@DiscriminatorValue(\"C\") @DiscriminatorColumn(name=\"subclass\", discriminatorType=CHAR)\n"
"public class Cat {\n"
" \n"
" @Id @GeneratedValue\n"
" public Integer getId() { return id; }\n"
" public void setId(Integer id) { this.id = id; }\n"
" private Integer id;\n"
"\n"
" public BigDecimal getWeight() { return weight; }\n"
" public void setWeight(BigDecimal weight) { this.weight = weight; }\n"
" private BigDecimal weight;\n"
"\n"
" @Temporal(DATE) @NotNull @Column(updatable=false)\n"
" public Date getBirthdate() { return birthdate; }\n"
" public void setBirthdate(Date birthdate) { this.birthdate = birthdate; }\n"
" private Date birthdate;\n"
"\n"
" @org.hibernate.annotations.Type(type=\"eg.types.ColorUserType\")\n"
" @NotNull @Column(updatable=false)\n"
" public ColorType getColor() { return color; }\n"
" public void setColor(ColorType color) { this.color = color; }\n"
" private ColorType color;\n"
"\n"
" @NotNull @Column(updatable=false)\n"
" public String getSex() { return sex; }\n"
" public void setSex(String sex) { this.sex = sex; }\n"
" private String sex;\n"
"\n"
" @NotNull @Column(updatable=false)\n"
" public Integer getLitterId() { return litterId; }\n"
" public void setLitterId(Integer litterId) { this.litterId = litterId; }\n"
" private Integer litterId;\n"
"\n"
" @ManyToOne @JoinColumn(name=\"mother_id\", updatable=false)\n"
" public Cat getMother() { return mother; }\n"
" public void setMother(Cat mother) { this.mother = mother; }\n"
" private Cat mother;\n"
"\n"
" @OneToMany(mappedBy=\"mother\") @OrderBy(\"litterId\")\n"
" public Set<Cat> getKittens() { return kittens; }\n"
" public void setKittens(Set<Cat> kittens) { this.kittens = kittens; }\n"
" private Set<Cat> kittens = new HashSet<Cat>();\n"
"}\n"
"\n"
"@Entity @DiscriminatorValue(\"D\")\n"
"public class DomesticCat extends Cat {\n"
"\n"
" public String getName() { return name; }\n"
" public void setName(String name) { this.name = name }\n"
" private String name;\n"
"}\n"
"\n"
"@Entity\n"
"public class Dog { ... }"
msgstr ""
#. Tag: para
#: basic_mapping.xml:73
#, no-c-format
msgid "The legacy hbm.xml approach uses an XML schema designed to be readable and hand-editable. The mapping language is Java-centric, meaning that mappings are constructed around persistent class declarations and not table declarations."
msgstr ""
#. Tag: para
#: basic_mapping.xml:78
#, no-c-format
msgid "Please note that even though many Hibernate users choose to write the XML by hand, a number of tools exist to generate the mapping document. These include XDoclet, Middlegen and AndroMDA."
msgstr ""
#. Tag: para
#: basic_mapping.xml:82
#, no-c-format
msgid "Here is an example mapping:"
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:84
#, no-c-format
msgid ""
"<?xml version=\"1.0\"?>\n"
"<!DOCTYPE hibernate-mapping PUBLIC\n"
" \"-//Hibernate/Hibernate Mapping DTD 3.0//EN\"\n"
" \"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd\">\n"
"\n"
"<hibernate-mapping package=\"eg\">\n"
"\n"
" <class name=\"Cat\"\n"
" table=\"cats\"\n"
" discriminator-value=\"C\">\n"
"\n"
" <id name=\"id\">\n"
" <generator class=\"native\"/>\n"
" </id>\n"
"\n"
" <discriminator column=\"subclass\"\n"
" type=\"character\"/>\n"
"\n"
" <property name=\"weight\"/>\n"
"\n"
" <property name=\"birthdate\"\n"
" type=\"date\"\n"
" not-null=\"true\"\n"
" update=\"false\"/>\n"
"\n"
" <property name=\"color\"\n"
" type=\"eg.types.ColorUserType\"\n"
" not-null=\"true\"\n"
" update=\"false\"/>\n"
"\n"
" <property name=\"sex\"\n"
" not-null=\"true\"\n"
" update=\"false\"/>\n"
"\n"
" <property name=\"litterId\"\n"
" column=\"litterId\"\n"
" update=\"false\"/>\n"
"\n"
" <many-to-one name=\"mother\"\n"
" column=\"mother_id\"\n"
" update=\"false\"/>\n"
"\n"
" <set name=\"kittens\"\n"
" inverse=\"true\"\n"
" order-by=\"litter_id\">\n"
" <key column=\"mother_id\"/>\n"
" <one-to-many class=\"Cat\"/>\n"
" </set>\n"
"\n"
" <subclass name=\"DomesticCat\"\n"
" discriminator-value=\"D\">\n"
"\n"
" <property name=\"name\"\n"
" type=\"string\"/>\n"
"\n"
" </subclass>\n"
"\n"
" </class>\n"
"\n"
" <class name=\"Dog\">\n"
" <!-- mapping for Dog could go here -->\n"
" </class>\n"
"\n"
"</hibernate-mapping>"
msgstr ""
#. Tag: para
#: basic_mapping.xml:86
#, no-c-format
msgid "We will now discuss the concepts of the mapping documents (both annotations and XML). We will only describe, however, the document elements and attributes that are used by Hibernate at runtime. The mapping document also contains some extra optional attributes and elements that affect the database schemas exported by the schema export tool (for example, the <literal> not-null</literal> attribute)."
msgstr ""
#. Tag: title
#: basic_mapping.xml:94
#, no-c-format
msgid "Entity"
msgstr ""
#. Tag: para
#: basic_mapping.xml:96
#, no-c-format
msgid "An entity is a regular Java object (aka POJO) which will be persisted by Hibernate."
msgstr ""
#. Tag: para
#: basic_mapping.xml:99
#, no-c-format
msgid "To mark an object as an entity in annotations, use the <classname>@Entity</classname> annotation."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:102
#, no-c-format
msgid ""
"@Entity\n"
"public class Flight implements Serializable {\n"
" Long id;\n"
"\n"
" @Id\n"
" public Long getId() { return id; }\n"
"\n"
" public void setId(Long id) { this.id = id; }\n"
"}"
msgstr ""
#. Tag: para
#: basic_mapping.xml:104
#, no-c-format
msgid "That's pretty much it, the rest is optional. There are however any options to tweak your entity mapping, let's explore them."
msgstr ""
#. Tag: para
#: basic_mapping.xml:107
#, no-c-format
msgid "<classname>@Table</classname> lets you define the table the entity will be persisted into. If undefined, the table name is the unqualified class name of the entity. You can also optionally define the catalog, the schema as well as unique constraints on the table."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:112
#, no-c-format
msgid ""
"@Entity\n"
"@Table(name=\"TBL_FLIGHT\", \n"
" schema=\"AIR_COMMAND\", \n"
" uniqueConstraints=\n"
" @UniqueConstraint(\n"
" name=\"flight_number\", \n"
" columnNames={\"comp_prefix\", \"flight_number\"} ) )\n"
"public class Flight implements Serializable {\n"
" @Column(name=\"comp_prefix\")\n"
" public String getCompagnyPrefix() { return companyPrefix; }\n"
"\n"
" @Column(name=\"flight_number\")\n"
" public String getNumber() { return number; }\n"
"}"
msgstr ""
#. Tag: para
#: basic_mapping.xml:114
#, no-c-format
msgid "The constraint name is optional (generated if left undefined). The column names composing the constraint correspond to the column names as defined before the Hibernate <classname>NamingStrategy</classname> is applied."
msgstr ""
#. Tag: para
#: basic_mapping.xml:119
#, no-c-format
msgid "<literal>@Entity.name</literal> lets you define the shortcut name of the entity you can used in JP-QL and HQL queries. It defaults to the unqualified class name of the class."
msgstr ""
#. Tag: para
#: basic_mapping.xml:123
#, no-c-format
msgid "Hibernate goes beyond the JPA specification and provide additional configurations. Some of them are hosted on <classname>@org.hibernate.annotations.Entity</classname>:"
msgstr ""
#. Tag: para
#: basic_mapping.xml:129
#, no-c-format
msgid "<literal>dynamicInsert</literal> / <literal>dynamicUpdate</literal> (defaults to false): specifies that <literal>INSERT</literal> / <literal>UPDATE</literal> SQL should be generated at runtime and contain only the columns whose values are not null. The <literal>dynamic-update</literal> and <literal>dynamic-insert</literal> settings are not inherited by subclasses. Although these settings can increase performance in some cases, they can actually decrease performance in others."
msgstr ""
#. Tag: para
#: basic_mapping.xml:140
#, no-c-format
msgid "<literal>selectBeforeUpdate</literal> (defaults to false): specifies that Hibernate should <emphasis>never</emphasis> perform an SQL <literal>UPDATE</literal> unless it is certain that an object is actually modified. Only when a transient object has been associated with a new session using <literal>update()</literal>, will Hibernate perform an extra SQL <literal>SELECT</literal> to determine if an <literal>UPDATE</literal> is actually required. Use of <literal>select-before-update</literal> will usually decrease performance. It is useful to prevent a database update trigger being called unnecessarily if you reattach a graph of detached instances to a <literal>Session</literal>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:154
#, no-c-format
msgid "<literal>polymorphisms</literal> (defaults to <literal>IMPLICIT</literal>): determines whether implicit or explicit query polymorphisms is used. <emphasis>Implicit</emphasis> polymorphisms means that instances of the class will be returned by a query that names any superclass or implemented interface or class, and that instances of any subclass of the class will be returned by a query that names the class itself. <emphasis>Explicit</emphasis> polymorphisms means that class instances will be returned only by queries that explicitly name that class. Queries that name the class will return only instances of subclasses mapped. For most purposes, the default <literal>polymorphisms=IMPLICIT</literal> is appropriate. Explicit polymorphisms is useful when two different classes are mapped to the same table This allows a \"lightweight\" class that contains a subset of the table columns."
msgstr ""
#. Tag: para
#: basic_mapping.xml:171
#, no-c-format
msgid "<literal>persister</literal>: specifies a custom <literal>ClassPersister</literal>. The <literal>persister</literal> attribute lets you customize the persistence strategy used for the class. You can, for example, specify your own subclass of <literal>org.hibernate.persister.EntityPersister</literal>, or you can even provide a completely new implementation of the interface <literal>org.hibernate.persister.ClassPersister</literal> that implements, for example, persistence via stored procedure calls, serialization to flat files or LDAP. See <literal>org.hibernate.test.CustomPersister</literal> for a simple example of \"persistence\" to a <literal>Hashtable</literal>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:185
#, no-c-format
msgid "<literal>optimisticLock</literal> (defaults to <literal>VERSION</literal>): determines the optimistic locking strategy. If you enable <literal>dynamicUpdate</literal>, you will have a choice of optimistic locking strategies:"
msgstr ""
#. Tag: para
#: basic_mapping.xml:192
#, no-c-format
msgid "<literal>version</literal>: check the version/timestamp columns"
msgstr ""
#. Tag: para
#: basic_mapping.xml:197
#, no-c-format
msgid "<literal>all</literal>: check all columns"
msgstr ""
#. Tag: para
#: basic_mapping.xml:201
#, no-c-format
msgid "<literal>dirty</literal>: check the changed columns, allowing some concurrent updates"
msgstr ""
#. Tag: para
#: basic_mapping.xml:206
#, no-c-format
msgid "<literal>none</literal>: do not use optimistic locking"
msgstr ""
#. Tag: para
#: basic_mapping.xml:211
#, no-c-format
msgid "It is <emphasis>strongly</emphasis> recommended that you use version/timestamp columns for optimistic locking with Hibernate. This strategy optimizes performance and correctly handles modifications made to detached instances (i.e. when <literal>Session.merge()</literal> is used)."
msgstr ""
#. Tag: para
#: basic_mapping.xml:220
#, no-c-format
msgid "Be sure to import <classname>@javax.persistence.Entity</classname> to mark a class as an entity. It's a common mistake to import <classname>@org.hibernate.annotations.Entity</classname> by accident."
msgstr ""
#. Tag: para
#: basic_mapping.xml:227
#, no-c-format
msgid "Some entities are not mutable. They cannot be updated or deleted by the application. This allows Hibernate to make some minor performance optimizations.. Use the <classname>@Immutable</classname> annotation."
msgstr ""
#. Tag: para
#: basic_mapping.xml:232
#, no-c-format
msgid "You can also alter how Hibernate deals with lazy initialization for this class. On <classname>@Proxy</classname>, use <literal>lazy</literal>=false to disable lazy fetching (not recommended). You can also specify an interface to use for lazy initializing proxies (defaults to the class itself): use <literal>proxyClass</literal> on <classname>@Proxy</classname>. Hibernate will initially return proxies (Javassist or CGLIB) that implement the named interface. The persistent object will load when a method of the proxy is invoked. See \"Initializing collections and proxies\" below."
msgstr ""
#. Tag: para
#: basic_mapping.xml:243
#, no-c-format
msgid "<classname>@BatchSize</classname> specifies a \"batch size\" for fetching instances of this class by identifier. Not yet loaded instances are loaded batch-size at a time (default 1)."
msgstr ""
#. Tag: para
#: basic_mapping.xml:247
#, no-c-format
msgid "You can specific an arbitrary SQL WHERE condition to be used when retrieving objects of this class. Use <classname>@Where</classname> for that."
msgstr ""
#. Tag: para
#: basic_mapping.xml:251
#, no-c-format
msgid "In the same vein, <classname>@Check</classname> lets you define an SQL expression used to generate a multi-row <emphasis>check</emphasis> constraint for automatic schema generation."
msgstr ""
#. Tag: para
#: basic_mapping.xml:255
#, no-c-format
msgid "There is no difference between a view and a base table for a Hibernate mapping. This is transparent at the database level, although some DBMS do not support views properly, especially with updates. Sometimes you want to use a view, but you cannot create one in the database (i.e. with a legacy schema). In this case, you can map an immutable and read-only entity to a given SQL subselect expression using <classname>@org.hibernate.annotations.Subselect</classname>:"
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:263
#, no-c-format
msgid ""
"@Entity\n"
"@Subselect(\"select item.name, max(bid.amount), count(*) \"\n"
" + \"from item \"\n"
" + \"join bid on bid.item_id = item.id \"\n"
" + \"group by item.name\")\n"
"@Synchronize( {\"item\", \"bid\"} ) //tables impacted\n"
"public class Summary {\n"
" @Id\n"
" public String getId() { return id; }\n"
" ...\n"
"}"
msgstr ""
#. Tag: para
#: basic_mapping.xml:265
#, no-c-format
msgid "Declare the tables to synchronize this entity with, ensuring that auto-flush happens correctly and that queries against the derived entity do not return stale data. The <literal><subselect></literal> is available both as an attribute and a nested mapping element."
msgstr ""
#. Tag: para
#: basic_mapping.xml:270
#, no-c-format
msgid "We will now explore the same options using the hbm.xml structure. You can declare a persistent class using the <literal>class</literal> element. For example:"
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:319
#, no-c-format
msgid ""
"<class\n"
" name=\"ClassName\"\n"
" table=\"tableName\"\n"
" discriminator-value=\"discriminator_value\"\n"
" mutable=\"true|false\"\n"
" schema=\"owner\"\n"
" catalog=\"catalog\"\n"
" proxy=\"ProxyInterface\"\n"
" dynamic-update=\"true|false\"\n"
" dynamic-insert=\"true|false\"\n"
" select-before-update=\"true|false\"\n"
" polymorphism=\"implicit|explicit\"\n"
" where=\"arbitrary sql where condition\"\n"
" persister=\"PersisterClass\"\n"
" batch-size=\"N\"\n"
" optimistic-lock=\"none|version|dirty|all\"\n"
" lazy=\"true|false\"\n"
" entity-name=\"EntityName\"\n"
" check=\"arbitrary sql check condition\"\n"
" rowid=\"rowid\"\n"
" subselect=\"SQL expression\"\n"
" abstract=\"true|false\"\n"
" node=\"element-name\"\n"
"/>"
msgstr ""
#. Tag: para
#: basic_mapping.xml:323
#, no-c-format
msgid "<literal>name</literal> (optional): the fully qualified Java class name of the persistent class or interface. If this attribute is missing, it is assumed that the mapping is for a non-POJO entity."
msgstr ""
#. Tag: para
#: basic_mapping.xml:330
#, no-c-format
msgid "<literal>table</literal> (optional - defaults to the unqualified class name): the name of its database table."
msgstr ""
#. Tag: para
#: basic_mapping.xml:335
#, no-c-format
msgid "<literal>discriminator-value</literal> (optional - defaults to the class name): a value that distinguishes individual subclasses that is used for polymorphic behavior. Acceptable values include <literal>null</literal> and <literal>not null</literal>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:343
#, no-c-format
msgid "<literal>mutable</literal> (optional - defaults to <literal>true</literal>): specifies that instances of the class are (not) mutable."
msgstr ""
#. Tag: para
#: basic_mapping.xml:349 basic_mapping.xml:2912
#, no-c-format
msgid "<literal>schema</literal> (optional): overrides the schema name specified by the root <literal><hibernate-mapping></literal> element."
msgstr ""
#. Tag: para
#: basic_mapping.xml:355 basic_mapping.xml:2918
#, no-c-format
msgid "<literal>catalog</literal> (optional): overrides the catalog name specified by the root <literal><hibernate-mapping></literal> element."
msgstr ""
#. Tag: para
#: basic_mapping.xml:361
#, no-c-format
msgid "<literal>proxy</literal> (optional): specifies an interface to use for lazy initializing proxies. You can specify the name of the class itself."
msgstr ""
#. Tag: para
#: basic_mapping.xml:367
#, no-c-format
msgid "<literal>dynamic-update</literal> (optional - defaults to <literal>false</literal>): specifies that <literal>UPDATE</literal> SQL should be generated at runtime and can contain only those columns whose values have changed."
msgstr ""
#. Tag: para
#: basic_mapping.xml:374
#, no-c-format
msgid "<literal>dynamic-insert</literal> (optional - defaults to <literal>false</literal>): specifies that <literal>INSERT</literal> SQL should be generated at runtime and contain only the columns whose values are not null."
msgstr ""
#. Tag: para
#: basic_mapping.xml:381
#, no-c-format
msgid "<literal>select-before-update</literal> (optional - defaults to <literal>false</literal>): specifies that Hibernate should <emphasis>never</emphasis> perform an SQL <literal>UPDATE</literal> unless it is certain that an object is actually modified. Only when a transient object has been associated with a new session using <literal>update()</literal>, will Hibernate perform an extra SQL <literal>SELECT</literal> to determine if an <literal>UPDATE</literal> is actually required."
msgstr ""
#. Tag: para
#: basic_mapping.xml:393
#, no-c-format
msgid "<literal>polymorphisms</literal> (optional - defaults to <literal>implicit</literal>): determines whether implicit or explicit query polymorphisms is used."
msgstr ""
#. Tag: para
#: basic_mapping.xml:399
#, no-c-format
msgid "<literal>where</literal> (optional): specifies an arbitrary SQL <literal>WHERE</literal> condition to be used when retrieving objects of this class."
msgstr ""
#. Tag: para
#: basic_mapping.xml:405
#, no-c-format
msgid "<literal>persister</literal> (optional): specifies a custom <literal>ClassPersister</literal>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:410
#, no-c-format
msgid "<literal>batch-size</literal> (optional - defaults to <literal>1</literal>): specifies a \"batch size\" for fetching instances of this class by identifier."
msgstr ""
#. Tag: para
#: basic_mapping.xml:416
#, no-c-format
msgid "<literal>optimistic-lock</literal> (optional - defaults to <literal>version</literal>): determines the optimistic locking strategy."
msgstr ""
#. Tag: para
#: basic_mapping.xml:422
#, no-c-format
msgid "<literal>lazy</literal> (optional): lazy fetching can be disabled by setting <literal>lazy=\"false\"</literal>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:427
#, no-c-format
msgid "<literal>entity-name</literal> (optional - defaults to the class name): Hibernate3 allows a class to be mapped multiple times, potentially to different tables. It also allows entity mappings that are represented by Maps or XML at the Java level. In these cases, you should provide an explicit arbitrary name for the entity. See <xref linkend=\"persistent-classes-dynamicmodels\"/> and <xref linkend=\"xml\"/> for more information."
msgstr ""
#. Tag: para
#: basic_mapping.xml:437
#, no-c-format
msgid "<literal>check</literal> (optional): an SQL expression used to generate a multi-row <emphasis>check</emphasis> constraint for automatic schema generation."
msgstr ""
#. Tag: para
#: basic_mapping.xml:443
#, no-c-format
msgid "<literal>rowid</literal> (optional): Hibernate can use ROWIDs on databases. On Oracle, for example, Hibernate can use the <literal>rowid</literal> extra column for fast updates once this option has been set to <literal>rowid</literal>. A ROWID is an implementation detail and represents the physical location of a stored tuple."
msgstr ""
#. Tag: para
#: basic_mapping.xml:452
#, no-c-format
msgid "<literal>subselect</literal> (optional): maps an immutable and read-only entity to a database subselect. This is useful if you want to have a view instead of a base table. See below for more information."
msgstr ""
#. Tag: para
#: basic_mapping.xml:459
#, no-c-format
msgid "<literal>abstract</literal> (optional): is used to mark abstract superclasses in <literal><union-subclass></literal> hierarchies."
msgstr ""
#. Tag: para
#: basic_mapping.xml:466
#, no-c-format
msgid "It is acceptable for the named persistent class to be an interface. You can declare implementing classes of that interface using the <literal><subclass></literal> element. You can persist any <emphasis>static</emphasis> inner class. Specify the class name using the standard form i.e. <literal>e.g.Foo$Bar</literal>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:472
#, no-c-format
msgid "Here is how to do a virtual view (subselect) in XML:"
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:474
#, no-c-format
msgid ""
"<class name=\"Summary\">\n"
" <subselect>\n"
" select item.name, max(bid.amount), count(*)\n"
" from item\n"
" join bid on bid.item_id = item.id\n"
" group by item.name\n"
" </subselect>\n"
" <synchronize table=\"item\"/>\n"
" <synchronize table=\"bid\"/>\n"
" <id name=\"name\"/>\n"
" ...\n"
"</class>"
msgstr ""
#. Tag: para
#: basic_mapping.xml:476
#, no-c-format
msgid "The <literal><subselect></literal> is available both as an attribute and a nested mapping element."
msgstr ""
#. Tag: title
#: basic_mapping.xml:481
#, no-c-format
msgid "Identifiers"
msgstr ""
#. Tag: para
#: basic_mapping.xml:483
#, no-c-format
msgid "Mapped classes <emphasis>must</emphasis> declare the primary key column of the database table. Most classes will also have a JavaBeans-style property holding the unique identifier of an instance."
msgstr ""
#. Tag: para
#: basic_mapping.xml:488
#, no-c-format
msgid "Mark the identifier property with <classname>@Id</classname>."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:491
#, no-c-format
msgid ""
"@Entity\n"
"public class Person {\n"
" @Id Integer getId() { ... }\n"
" ...\n"
"}"
msgstr ""
#. Tag: para
#: basic_mapping.xml:493
#, no-c-format
msgid "In hbm.xml, use the <literal><id></literal> element which defines the mapping from that property to the primary key column."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:509
#, no-c-format
msgid ""
"<id\n"
" name=\"propertyName\"\n"
" type=\"typename\"\n"
" column=\"column_name\"\n"
" unsaved-value=\"null|any|none|undefined|id_value\"\n"
" access=\"field|property|ClassName\">\n"
" node=\"element-name|@attribute-name|element/@attribute|.\"\n"
"\n"
" <generator class=\"generatorClass\"/>\n"
"</id>"
msgstr ""
#. Tag: para
#: basic_mapping.xml:513
#, no-c-format
msgid "<literal>name</literal> (optional): the name of the identifier property."
msgstr ""
#. Tag: para
#: basic_mapping.xml:518 basic_mapping.xml:2141
#, no-c-format
msgid "<literal>type</literal> (optional): a name that indicates the Hibernate type."
msgstr ""
#. Tag: para
#: basic_mapping.xml:523
#, no-c-format
msgid "<literal>column</literal> (optional - defaults to the property name): the name of the primary key column."
msgstr ""
#. Tag: para
#: basic_mapping.xml:528
#, no-c-format
msgid "<literal>unsaved-value</literal> (optional - defaults to a \"sensible\" value): an identifier property value that indicates an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded in a previous session."
msgstr ""
#. Tag: para
#: basic_mapping.xml:536
#, no-c-format
msgid "<literal>access</literal> (optional - defaults to <literal>property</literal>): the strategy Hibernate should use for accessing the property value."
msgstr ""
#. Tag: para
#: basic_mapping.xml:543
#, no-c-format
msgid "If the <literal>name</literal> attribute is missing, it is assumed that the class has no identifier property."
msgstr ""
#. Tag: para
#: basic_mapping.xml:546
#, no-c-format
msgid "The <literal>unsaved-value</literal> attribute is almost never needed in Hibernate3 and indeed has no corresponding element in annotations."
msgstr ""
#. Tag: para
#: basic_mapping.xml:550
#, no-c-format
msgid "You can also declare the identifier as a composite identifier. This allows access to legacy data with composite keys. Its use is strongly discouraged for anything else."
msgstr ""
#. Tag: title
#: basic_mapping.xml:555
#, no-c-format
msgid "Composite identifier"
msgstr ""
#. Tag: para
#: basic_mapping.xml:557
#, no-c-format
msgid "You can define a composite primary key through several syntaxes:"
msgstr ""
#. Tag: para
#: basic_mapping.xml:562
#, no-c-format
msgid "use a component type to represent the identifier and map it as a property in the entity: you then annotated the property as <classname>@EmbeddedId</classname>. The component type has to be <classname>Serializable</classname>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:569
#, no-c-format
msgid "map multiple properties as <classname>@Id</classname> properties: the identifier type is then the entity class itself and needs to be <classname>Serializable</classname>. This approach is unfortunately not standard and only supported by Hibernate."
msgstr ""
#. Tag: para
#: basic_mapping.xml:577
#, no-c-format
msgid "map multiple properties as <classname>@Id</classname> properties and declare an external class to be the identifier type. This class, which needs to be <classname>Serializable</classname>, is declared on the entity via the <classname>@IdClass</classname> annotation. The identifier type must contain the same properties as the identifier properties of the entity: each property name must be the same, its type must be the same as well if the entity property is of a basic type, its type must be the type of the primary key of the associated entity if the entity property is an association (either a <classname>@OneToOne</classname> or a <classname>@ManyToOne</classname>)."
msgstr ""
#. Tag: para
#: basic_mapping.xml:592
#, no-c-format
msgid "As you can see the last case is far from obvious. It has been inherited from the dark ages of EJB 2 for backward compatibilities and we recommend you not to use it (for simplicity sake)."
msgstr ""
#. Tag: para
#: basic_mapping.xml:596
#, no-c-format
msgid "Let's explore all three cases using examples."
msgstr ""
#. Tag: title
#: basic_mapping.xml:599
#, no-c-format
msgid "id as a property using a component type"
msgstr ""
#. Tag: para
#: basic_mapping.xml:601
#, no-c-format
msgid "Here is a simple example of <classname>@EmbeddedId</classname>."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:604
#, no-c-format
msgid ""
"@Entity\n"
"class User {\n"
" @EmbeddedId\n"
" @AttributeOverride(name=\"firstName\", column=@Column(name=\"fld_firstname\")\n"
" UserId id;\n"
"\n"
" Integer age;\n"
"}\n"
"\n"
"@Embeddable\n"
"class UserId implements Serializable {\n"
" String firstName;\n"
" String lastName;\n"
"}"
msgstr ""
#. Tag: para
#: basic_mapping.xml:606
#, no-c-format
msgid "You can notice that the <classname>UserId</classname> class is serializable. To override the column mapping, use <classname>@AttributeOverride</classname>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:610
#, no-c-format
msgid "An embedded id can itself contains the primary key of an associated entity."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:613
#, no-c-format
msgid ""
"@Entity\n"
"class Customer {\n"
" @EmbeddedId CustomerId id;\n"
" boolean preferredCustomer;\n"
"\n"
" @MapsId(\"userId\")\n"
" @JoinColumns({\n"
" @JoinColumn(name=\"userfirstname_fk\", referencedColumnName=\"firstName\"),\n"
" @JoinColumn(name=\"userlastname_fk\", referencedColumnName=\"lastName\")\n"
" })\n"
" @OneToOne User user;\n"
"}\n"
"\n"
"@Embeddable\n"
"class CustomerId implements Serializable {\n"
" UserId userId;\n"
" String customerNumber;\n"
"\n"
" //implements equals and hashCode\n"
"}\n"
"\n"
"@Entity \n"
"class User {\n"
" @EmbeddedId UserId id;\n"
" Integer age;\n"
"}\n"
"\n"
"@Embeddable\n"
"class UserId implements Serializable {\n"
" String firstName;\n"
" String lastName;\n"
"\n"
" //implements equals and hashCode\n"
"}"
msgstr ""
#. Tag: para
#: basic_mapping.xml:615
#, no-c-format
msgid "In the embedded id object, the association is represented as the identifier of the associated entity. But you can link its value to a regular association in the entity via the <classname>@MapsId</classname> annotation. The <classname>@MapsId</classname> value correspond to the property name of the embedded id object containing the associated entity's identifier. In the database, it means that the <literal>Customer.user</literal> and the <literal>CustomerId.userId</literal> properties share the same underlying column (<literal>user_fk</literal> in this case)."
msgstr ""
#. Tag: para
#: basic_mapping.xml:627
#, no-c-format
msgid "The component type used as identifier must implement <methodname>equals()</methodname> and <methodname>hashCode()</methodname>."
msgstr ""
#. Tag: para
#: basic_mapping.xml:632
#, no-c-format
msgid "In practice, your code only sets the <literal>Customer.user</literal> property and the user id value is copied by Hibernate into the <literal>CustomerId.userId</literal> property."
msgstr ""
#. Tag: para
#: basic_mapping.xml:638
#, no-c-format
msgid "The id value can be copied as late as flush time, don't rely on it until after flush time."
msgstr ""
#. Tag: para
#: basic_mapping.xml:642
#, no-c-format
msgid "While not supported in JPA, Hibernate lets you place your association directly in the embedded id component (instead of having to use the <classname>@MapsId</classname> annotation)."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:646
#, no-c-format
msgid ""
"@Entity\n"
"class Customer {\n"
" @EmbeddedId CustomerId id;\n"
" boolean preferredCustomer;\n"
"}\n"
"\n"
"@Embeddable\n"
"class CustomerId implements Serializable {\n"
" @OneToOne\n"
" @JoinColumns({\n"
" @JoinColumn(name=\"userfirstname_fk\", referencedColumnName=\"firstName\"),\n"
" @JoinColumn(name=\"userlastname_fk\", referencedColumnName=\"lastName\")\n"
" }) \n"
" User user;\n"
" String customerNumber;\n"
"\n"
" //implements equals and hashCode\n"
"}\n"
"\n"
"@Entity \n"
"class User {\n"
" @EmbeddedId UserId id;\n"
" Integer age;\n"
"}\n"
"\n"
"@Embeddable\n"
"class UserId implements Serializable {\n"
" String firstName;\n"
" String lastName;\n"
"\n"
"\n"
" //implements equals and hashCode\n"
"}"
msgstr ""
#. Tag: para
#: basic_mapping.xml:648
#, no-c-format
msgid "Let's now rewrite these examples using the hbm.xml syntax."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:651
#, no-c-format
msgid ""
"<composite-id\n"
" name=\"propertyName\"\n"
" class=\"ClassName\"\n"
" mapped=\"true|false\"\n"
" access=\"field|property|ClassName\"\n"
" node=\"element-name|.\">\n"
"\n"
" <key-property name=\"propertyName\" type=\"typename\" column=\"column_name\"/>\n"
" <key-many-to-one name=\"propertyName\" class=\"ClassName\" column=\"column_name\"/>\n"
" ......\n"
"</composite-id>"
msgstr ""
#. Tag: para
#: basic_mapping.xml:653
#, no-c-format
msgid "First a simple example:"
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:655
#, no-c-format
msgid ""
"<class name=\"User\">\n"
" <composite-id name=\"id\" class=\"UserId\">\n"
" <key-property name=\"firstName\" column=\"fld_firstname\"/>\n"
" <key-property name=\"lastName\"/>\n"
" </composite-id>\n"
"</class>"
msgstr ""
#. Tag: para
#: basic_mapping.xml:657
#, no-c-format
msgid "Then an example showing how an association can be mapped."
msgstr ""
#. Tag: programlisting
#: basic_mapping.xml:660
#, no-c-format
msgid ""
"<class name=\"Customer\">\n"
" <composite-id name=\"id\" class=\"CustomerId\">\n"
" <key-property name=\"firstName\" column=\"userfirstname_fk\"/>\n"
" <key-property name=\"lastName\" column=\"userfirstname_fk\"/>\n"
" <key-property name=\"customerNumber\"/>\n"
" </composite-id>\n"
"\n"
" <property name=\"preferredCustomer\"/>\n"
"\n"
" <many-to-one name=\"user\">\n"
" <column name=\"userfirstname_fk\" updatable=\"false\" insertable=\"false\"/>\n"
" <column name=\"userlastname_fk\" updatable=\"false\" insertable=\"false\"/>\n"
" </many-to-one>\n"
"</class>\n"
"\n"
"<class name=\"User\">\n"
" <composite-id name=\"id\" class=\"UserId\">\n"
" <key-property name=\"firstName\"/>\n"
" <key-property name=\"lastName\"/>\n"
" </composite-id>\n"
"\n"