Skip to content
This repository
Browse code

Added a note about under development chapters and pushed the planning…

… stuff into Notes.
  • Loading branch information...
commit f5b1dda234bd1b70608aad9a14c466c576d04c31 1 parent 8833365
Tyler Weir authored
632  chap-JPA.lyx
... ...
@@ -1,8 +1,9 @@
1  
-#LyX 1.5.3 created this file. For more info see http://www.lyx.org/
2  
-\lyxformat 276
  1
+#LyX 1.6.0 created this file. For more info see http://www.lyx.org/
  2
+\lyxformat 345
3 3
 \begin_document
4 4
 \begin_header
5 5
 \textclass book
  6
+\use_default_options false
6 7
 \language english
7 8
 \inputencoding auto
8 9
 \font_roman default
@@ -13,9 +14,11 @@
13 14
 \font_osf false
14 15
 \font_sf_scale 100
15 16
 \font_tt_scale 100
  17
+
16 18
 \graphics default
17 19
 \paperfontsize default
18 20
 \spacing single
  21
+\use_hyperref false
19 22
 \papersize default
20 23
 \use_geometry false
21 24
 \use_amsmath 1
@@ -44,13 +47,41 @@ JPA Integration
44 47
 \end_layout
45 48
 
46 49
 \begin_layout Standard
  50
+\begin_inset Box Framed
  51
+position "t"
  52
+hor_pos "c"
  53
+has_inner_box 0
  54
+inner_pos "t"
  55
+use_parbox 0
  56
+width "100col%"
  57
+special "none"
  58
+height "1in"
  59
+height_special "totalheight"
  60
+status collapsed
  61
+
  62
+\begin_layout Plain Layout
  63
+This chapter is still under active development.
  64
+ The contents will change.
  65
+\end_layout
  66
+
  67
+\end_inset
  68
+
  69
+
  70
+\end_layout
  71
+
  72
+\begin_layout Standard
47 73
 The Java Persistence API
48 74
 \begin_inset Foot
49 75
 status collapsed
50 76
 
51  
-\begin_layout Standard
52  
-\begin_inset LatexCommand htmlurl
53  
-target "http://java.sun.com/javaee/overview/faq/persistence.jsp"
  77
+\begin_layout Plain Layout
  78
+\begin_inset Flex URL
  79
+status collapsed
  80
+
  81
+\begin_layout Plain Layout
  82
+
  83
+http://java.sun.com/javaee/overview/faq/persistence.jsp
  84
+\end_layout
54 85
 
55 86
 \end_inset
56 87
 
@@ -60,8 +91,12 @@ target "http://java.sun.com/javaee/overview/faq/persistence.jsp"
60 91
 \end_inset
61 92
 
62 93
 , or JPA
63  
-\begin_inset LatexCommand index
64  
-name "JPA"
  94
+\begin_inset Index
  95
+status collapsed
  96
+
  97
+\begin_layout Plain Layout
  98
+JPA
  99
+\end_layout
65 100
 
66 101
 \end_inset
67 102
 
@@ -71,8 +106,12 @@ name "JPA"
71 106
  JPA was developed as part of the EJB3 specification, with the goal of simplifyi
72 107
 ng the persistence model.
73 108
  Prior versions had used the Container Managed Persistence (CMP
74  
-\begin_inset LatexCommand index
75  
-name "CMP"
  109
+\begin_inset Index
  110
+status collapsed
  111
+
  112
+\begin_layout Plain Layout
  113
+CMP
  114
+\end_layout
76 115
 
77 116
 \end_inset
78 117
 
@@ -80,16 +119,24 @@ name "CMP"
80 119
  and XML descriptors.
81 120
  As part of the overarching theme of EJB3 to simplify and use configuration
82 121
  by convention, JPA uses annotations
83  
-\begin_inset LatexCommand index
84  
-name "annotations"
  122
+\begin_inset Index
  123
+status collapsed
  124
+
  125
+\begin_layout Plain Layout
  126
+annotations
  127
+\end_layout
85 128
 
86 129
 \end_inset
87 130
 
88 131
  heavily, while allowing for targetted overrides of behavior via XML descriptors.
89 132
  JPA also does away with many of the interfaces used in CMP and provides
90 133
  a single EntityManager
91  
-\begin_inset LatexCommand index
92  
-name "EntityManager"
  134
+\begin_inset Index
  135
+status collapsed
  136
+
  137
+\begin_layout Plain Layout
  138
+EntityManager
  139
+\end_layout
93 140
 
94 141
 \end_inset
95 142
 
@@ -97,20 +144,32 @@ name "EntityManager"
97 144
  An additional benefit is that JPA was designed so that it could be used
98 145
  both inside and outside of the Enterprise container, and several projects
99 146
  (Hibernate
100  
-\begin_inset LatexCommand index
101  
-name "Hibernate"
  147
+\begin_inset Index
  148
+status collapsed
  149
+
  150
+\begin_layout Plain Layout
  151
+Hibernate
  152
+\end_layout
102 153
 
103 154
 \end_inset
104 155
 
105 156
 , TopLink
106  
-\begin_inset LatexCommand index
107  
-name "TopLink"
  157
+\begin_inset Index
  158
+status collapsed
  159
+
  160
+\begin_layout Plain Layout
  161
+TopLink
  162
+\end_layout
108 163
 
109 164
 \end_inset
110 165
 
111 166
 , JPOX
112  
-\begin_inset LatexCommand index
113  
-name "JPOX"
  167
+\begin_inset Index
  168
+status collapsed
  169
+
  170
+\begin_layout Plain Layout
  171
+JPOX
  172
+\end_layout
114 173
 
115 174
 \end_inset
116 175
 
@@ -119,7 +178,8 @@ name "JPOX"
119 178
 
120 179
 \begin_layout Standard
121 180
 As we've seen in chapter 
122  
-\begin_inset LatexCommand ref
  181
+\begin_inset CommandInset ref
  182
+LatexCommand ref
123 183
 reference "cha:mapper_and_record"
124 184
 
125 185
 \end_inset
@@ -143,7 +203,7 @@ JPA gives you more flexibility with complex and/or large schemas.
143 203
 \begin_inset Note Note
144 204
 status open
145 205
 
146  
-\begin_layout Standard
  206
+\begin_layout Plain Layout
147 207
 TODO: is it Record or Mapper?
148 208
 \end_layout
149 209
 
@@ -164,7 +224,7 @@ accessed objects in memory so that you avoid hitting the database entirely
164 224
 \begin_inset Note Note
165 225
 status open
166 226
 
167  
-\begin_layout Standard
  227
+\begin_layout Plain Layout
168 228
 May need to remove this if it's not true by printing
169 229
 \end_layout
170 230
 
@@ -184,8 +244,12 @@ In order to provide a concrete example to build on while learning how to
184 244
  integrate JPA, we'll be building a small Lift app to manage a library of
185 245
  books.
186 246
  The completed example is available under the Lift Git
187  
-\begin_inset LatexCommand index
188  
-name "Git"
  247
+\begin_inset Index
  248
+status collapsed
  249
+
  250
+\begin_layout Plain Layout
  251
+Git
  252
+\end_layout
189 253
 
190 254
 \end_inset
191 255
 
@@ -199,7 +263,8 @@ JPADemo
199 263
 
200 264
 .
201 265
  Basic coverage of the JPA operations is in section 
202  
-\begin_inset LatexCommand vref
  266
+\begin_inset CommandInset ref
  267
+LatexCommand vref
203 268
 reference "sec:JPA-Examples"
204 269
 
205 270
 \end_inset
@@ -210,15 +275,25 @@ reference "sec:JPA-Examples"
210 275
 \begin_inset Foot
211 276
 status collapsed
212 277
 
213  
-\begin_layout Standard
214  
-\begin_inset LatexCommand htmlurl
215  
-target "http://java.sun.com/developer/technicalArticles/J2EE/jpa/"
  278
+\begin_layout Plain Layout
  279
+\begin_inset Flex URL
  280
+status collapsed
  281
+
  282
+\begin_layout Plain Layout
  283
+
  284
+http://java.sun.com/developer/technicalArticles/J2EE/jpa/
  285
+\end_layout
216 286
 
217 287
 \end_inset
218 288
 
219 289
 , 
220  
-\begin_inset LatexCommand htmlurl
221  
-target "http://www.jpox.org/docs/1_2/tutorials/jpa_tutorial.html"
  290
+\begin_inset Flex URL
  291
+status collapsed
  292
+
  293
+\begin_layout Plain Layout
  294
+
  295
+http://www.jpox.org/docs/1_2/tutorials/jpa_tutorial.html
  296
+\end_layout
222 297
 
223 298
 \end_inset
224 299
 
@@ -229,8 +304,12 @@ target "http://www.jpox.org/docs/1_2/tutorials/jpa_tutorial.html"
229 304
 
230 305
 .
231 306
  Our first step is to set up a master project
232  
-\begin_inset LatexCommand index
233  
-name "master project"
  307
+\begin_inset Index
  308
+status collapsed
  309
+
  310
+\begin_layout Plain Layout
  311
+master project
  312
+\end_layout
234 313
 
235 314
 \end_inset
236 315
 
@@ -238,7 +317,7 @@ name "master project"
238 317
 \begin_inset Note Note
239 318
 status open
240 319
 
241  
-\begin_layout Standard
  320
+\begin_layout Plain Layout
242 321
 Will the Maven chapter have a section on master/module projects?
243 322
 \end_layout
244 323
 
@@ -248,14 +327,19 @@ Will the Maven chapter have a section on master/module projects?
248 327
  This project will have two modules under it, one for the JPA library and
249 328
  one for the Lift application.
250 329
  The only thing we actually need for the master project is the pom.xml
251  
-\begin_inset LatexCommand index
252  
-name "pom.xml"
  330
+\begin_inset Index
  331
+status collapsed
  332
+
  333
+\begin_layout Plain Layout
  334
+pom.xml
  335
+\end_layout
253 336
 
254 337
 \end_inset
255 338
 
256 339
 .
257 340
  The complete pom.xml is shown in section 
258  
-\begin_inset LatexCommand vref
  341
+\begin_inset CommandInset ref
  342
+LatexCommand vref
259 343
 reference "lst:JPA-Master-pom.xml"
260 344
 
261 345
 \end_inset
@@ -271,8 +355,12 @@ reference "lst:JPA-Master-pom.xml"
271 355
 The master pom.xml sets up some basic dependencies and plugin configurations
272 356
  which the modules will inherit.
273 357
  Our next step will be to create the JPA module using an archetype
274  
-\begin_inset LatexCommand index
275  
-name "archetype"
  358
+\begin_inset Index
  359
+status collapsed
  360
+
  361
+\begin_layout Plain Layout
  362
+archetype
  363
+\end_layout
276 364
 
277 365
 \end_inset
278 366
 
@@ -280,7 +368,7 @@ name "archetype"
280 368
 \begin_inset Note Note
281 369
 status open
282 370
 
283  
-\begin_layout Standard
  371
+\begin_layout Plain Layout
284 372
 I need to get the JPA archetype set up
285 373
 \end_layout
286 374
 
@@ -306,8 +394,12 @@ Scala JPA
306 394
 
307 395
 \begin_layout Subsection
308 396
 Entity Classes
309  
-\begin_inset LatexCommand index
310  
-name "entity class"
  397
+\begin_inset Index
  398
+status collapsed
  399
+
  400
+\begin_layout Plain Layout
  401
+entity class
  402
+\end_layout
311 403
 
312 404
 \end_inset
313 405
 
@@ -319,7 +411,8 @@ The main components of a JPA library are the entity classes that comprise
319 411
  your data model.
320 412
  For our example application we need two primary entities: Author and Book.
321 413
  Let's take a look at the Author class first, shown in listing 
322  
-\begin_inset LatexCommand vref
  414
+\begin_inset CommandInset ref
  415
+LatexCommand vref
323 416
 reference "lst:Author.scala"
324 417
 
325 418
 \end_inset
@@ -337,7 +430,7 @@ reference "lst:Author.scala"
337 430
 \begin_inset Note Note
338 431
 status open
339 432
 
340  
-\begin_layout Standard
  433
+\begin_layout Plain Layout
341 434
 I think this changes in 2.8
342 435
 \end_layout
343 436
 
@@ -353,9 +446,14 @@ I think this changes in 2.8
353 446
 \begin_inset Foot
354 447
 status open
355 448
 
356  
-\begin_layout Standard
357  
-\begin_inset LatexCommand htmlurl
358  
-target "https://lampsvn.epfl.ch/trac/scala/ticket/294"
  449
+\begin_layout Plain Layout
  450
+\begin_inset Flex URL
  451
+status collapsed
  452
+
  453
+\begin_layout Plain Layout
  454
+
  455
+https://lampsvn.epfl.ch/trac/scala/ticket/294
  456
+\end_layout
359 457
 
360 458
 \end_inset
361 459
 
@@ -369,14 +467,19 @@ target "https://lampsvn.epfl.ch/trac/scala/ticket/294"
369 467
 \end_layout
370 468
 
371 469
 \begin_layout Subsection
372  
-\begin_inset LatexCommand label
  470
+\begin_inset CommandInset label
  471
+LatexCommand label
373 472
 name "sub:Using-the-orm.xml"
374 473
 
375 474
 \end_inset
376 475
 
377 476
 Using the orm.xml
378  
-\begin_inset LatexCommand index
379  
-name "orm.xml"
  477
+\begin_inset Index
  478
+status collapsed
  479
+
  480
+\begin_layout Plain Layout
  481
+orm.xml
  482
+\end_layout
380 483
 
381 484
 \end_inset
382 485
 
@@ -391,15 +494,20 @@ As we stated in the last section, there are some instances where the Scala
391 494
  column names, etc) should be separate from code.
392 495
  Because of that, JPA allows you to specify an external mapping descriptor
393 496
  to define and/or override the mappings for your entity classes
394  
-\begin_inset LatexCommand index
395  
-name "entity classes"
  497
+\begin_inset Index
  498
+status collapsed
  499
+
  500
+\begin_layout Plain Layout
  501
+entity classes
  502
+\end_layout
396 503
 
397 504
 \end_inset
398 505
 
399 506
 .
400 507
  The basic orm.xml file starts with the DTD type declaration, as shown in
401 508
  listing 
402  
-\begin_inset LatexCommand vref
  509
+\begin_inset CommandInset ref
  510
+LatexCommand vref
403 511
 reference "lst:orm.xml"
404 512
 
405 513
 \end_inset
@@ -412,8 +520,13 @@ reference "lst:orm.xml"
412 520
  Putting them in the orm.xml allows us to modify them without requiring a
413 521
  recompile.
414 522
  The complete XML Schema Definition can be found at 
415  
-\begin_inset LatexCommand htmlurl
416  
-target "http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
  523
+\begin_inset Flex URL
  524
+status collapsed
  525
+
  526
+\begin_layout Plain Layout
  527
+
  528
+http://java.sun.com/xml/ns/persistence/orm_1_0.xsd
  529
+\end_layout
417 530
 
418 531
 \end_inset
419 532
 
@@ -427,7 +540,8 @@ In this case we have used the orm.xml file to augment our entity classes.
427 540
  Suppose we wished to change the column name for the Author's name property.
428 541
  We can add (per the XSD) a section to the Author entity element as shown
429 542
  in listing 
430  
-\begin_inset LatexCommand ref
  543
+\begin_inset CommandInset ref
  544
+LatexCommand ref
431 545
 reference "lst:JPA-Author-override"
432 546
 
433 547
 \end_inset
@@ -445,8 +559,12 @@ attribute-override
445 559
  This gives us an extremely powerful method for controlling our schema mapping
446 560
  outside of the source code.
447 561
  We can also add named queries
448  
-\begin_inset LatexCommand index
449  
-name "named queries"
  562
+\begin_inset Index
  563
+status collapsed
  564
+
  565
+\begin_layout Plain Layout
  566
+named queries
  567
+\end_layout
450 568
 
451 569
 \end_inset
452 570
 
@@ -460,12 +578,13 @@ lstparams "basicstyle={\footnotesize},float,frame=single,language=XML"
460 578
 inline false
461 579
 status open
462 580
 
463  
-\begin_layout Standard
  581
+\begin_layout Plain Layout
464 582
 
465 583
 \begin_inset Caption
466 584
 
467  
-\begin_layout Standard
468  
-\begin_inset LatexCommand label
  585
+\begin_layout Plain Layout
  586
+\begin_inset CommandInset label
  587
+LatexCommand label
469 588
 name "lst:JPA-Author-override"
470 589
 
471 590
 \end_inset
@@ -478,37 +597,37 @@ Author override
478 597
   <entity class="Author">
479 598
 \end_layout
480 599
 
481  
-\begin_layout Standard
  600
+\begin_layout Plain Layout
482 601
 
483 602
     <named-query name="findAllAuthors">
484 603
 \end_layout
485 604
 
486  
-\begin_layout Standard
  605
+\begin_layout Plain Layout
487 606
 
488 607
       <query><![CDATA[from Author a order by a.name]]></query>
489 608
 \end_layout
490 609
 
491  
-\begin_layout Standard
  610
+\begin_layout Plain Layout
492 611
 
493 612
     </named-query>
494 613
 \end_layout
495 614
 
496  
-\begin_layout Standard
  615
+\begin_layout Plain Layout
497 616
 
498 617
     <attribute-override name="name">
499 618
 \end_layout
500 619
 
501  
-\begin_layout Standard
  620
+\begin_layout Plain Layout
502 621
 
503 622
       <column name="author_name" length="30" />
504 623
 \end_layout
505 624
 
506  
-\begin_layout Standard
  625
+\begin_layout Plain Layout
507 626
 
508 627
     </attribute-override>
509 628
 \end_layout
510 629
 
511  
-\begin_layout Standard
  630
+\begin_layout Plain Layout
512 631
 
513 632
   </entity>
514 633
 \end_layout
@@ -537,7 +656,8 @@ persist
537 656
 merge
538 657
 \family default
539 658
  methods (section 
540  
-\begin_inset LatexCommand ref
  659
+\begin_inset CommandInset ref
  660
+LatexCommand ref
541 661
 reference "sub:Persisting,-merging-and-removing"
542 662
 
543 663
 \end_inset
@@ -579,7 +699,7 @@ JPA can handle any Java primitive type, their corresponding Object versions
579 699
 \begin_inset Foot
580 700
 status collapsed
581 701
 
582  
-\begin_layout Standard
  702
+\begin_layout Plain Layout
583 703
 It can technically handle more; see the JPA spec, section 2.1.1 for details
584 704
 \end_layout
585 705
 
@@ -589,8 +709,12 @@ It can technically handle more; see the JPA spec, section 2.1.1 for details
589 709
  Occasionally, though, you may have a requirement for a type that doesn't
590 710
  fit directly with those specifications.
591 711
  One example in particular would be Scala's enumerations
592  
-\begin_inset LatexCommand index
593  
-name "enumerations"
  712
+\begin_inset Index
  713
+status collapsed
  714
+
  715
+\begin_layout Plain Layout
  716
+enumerations
  717
+\end_layout
594 718
 
595 719
 \end_inset
596 720
 
@@ -612,7 +736,8 @@ Java
612 736
 We begin by implementing a few helper classes besides the Genre enumeration
613 737
  itself.
614 738
  First, we define an Enumv trait, shown in listing 
615  
-\begin_inset LatexCommand vref
  739
+\begin_inset CommandInset ref
  740
+LatexCommand vref
616 741
 reference "lst:Enumv-Trait"
617 742
 
618 743
 \end_inset
@@ -640,7 +765,8 @@ valueOf
640 765
 In order to actually convert the Enumeration class into the proper database
641 766
  type (String, Int, etc), we need to implement the Hibernate UserType interface,
642 767
  shown in listing 
643  
-\begin_inset LatexCommand vref
  768
+\begin_inset CommandInset ref
  769
+LatexCommand vref
644 770
 reference "lst:EnumvType"
645 771
 
646 772
 \end_inset
@@ -711,12 +837,13 @@ lstparams "basicstyle={\scriptsize},breaklines=true,firstline=3,float,frame=sing
711 837
 inline false
712 838
 status open
713 839
 
714  
-\begin_layout Standard
  840
+\begin_layout Plain Layout
715 841
 
716 842
 \begin_inset Caption
717 843
 
718  
-\begin_layout Standard
719  
-\begin_inset LatexCommand label
  844
+\begin_layout Plain Layout
  845
+\begin_inset CommandInset label
  846
+LatexCommand label
720 847
 name "lst:Genre-and-GenreType"
721 848
 
722 849
 \end_inset
@@ -729,45 +856,45 @@ Genre and GenreType
729 856
 package com.foo.jpaweb.model
730 857
 \end_layout
731 858
 
732  
-\begin_layout Standard
  859
+\begin_layout Plain Layout
733 860
 
734 861
 \end_layout
735 862
 
736  
-\begin_layout Standard
  863
+\begin_layout Plain Layout
737 864
 
738 865
 object Genre extends Enumeration with Enumv {
739 866
 \end_layout
740 867
 
741  
-\begin_layout Standard
  868
+\begin_layout Plain Layout
742 869
 
743 870
   val Mystery = Value("Mystery", "Mystery")
744 871
 \end_layout
745 872
 
746  
-\begin_layout Standard
  873
+\begin_layout Plain Layout
747 874
 
748 875
   val Science = Value("Science", "Science")
749 876
 \end_layout
750 877
 
751  
-\begin_layout Standard
  878
+\begin_layout Plain Layout
752 879
 
753 880
   val Theater = Value("Theater", "Drama literature")
754 881
 \end_layout
755 882
 
756  
-\begin_layout Standard
  883
+\begin_layout Plain Layout
757 884
 
758 885
   // more values here...
759 886
 \end_layout
760 887
 
761  
-\begin_layout Standard
  888
+\begin_layout Plain Layout
762 889
 
763 890
 }
764 891
 \end_layout
765 892
 
766  
-\begin_layout Standard
  893
+\begin_layout Plain Layout
767 894
 
768 895
 \end_layout
769 896
 
770  
-\begin_layout Standard
  897
+\begin_layout Plain Layout
771 898
 
772 899
 class GenreType extends EnumvType(Genre) {}
773 900
 \end_layout
@@ -780,7 +907,8 @@ class GenreType extends EnumvType(Genre) {}
780 907
 \begin_layout Standard
781 908
 Finally, the Genre object and the associated GenreType is shown in listing
782 909
  
783  
-\begin_inset LatexCommand ref
  910
+\begin_inset CommandInset ref
  911
+LatexCommand ref
784 912
 reference "lst:Genre-and-GenreType"
785 913
 
786 914
 \end_inset
@@ -795,7 +923,8 @@ reference "lst:Genre-and-GenreType"
795 923
 var
796 924
 \family default
797 925
  and annotate it with the @Type annotation, as shown in listing 
798  
-\begin_inset LatexCommand ref
  926
+\begin_inset CommandInset ref
  927
+LatexCommand ref
799 928
 reference "lst:Using-the-@Type"
800 929
 
801 930
 \end_inset
@@ -818,12 +947,13 @@ lstparams "basicstyle={\scriptsize},float,frame=single"
818 947
 inline false
819 948
 status open
820 949
 
821  
-\begin_layout Standard
  950
+\begin_layout Plain Layout
822 951
 
823 952
 \begin_inset Caption
824 953
 
825  
-\begin_layout Standard
826  
-\begin_inset LatexCommand label
  954
+\begin_layout Plain Layout
  955
+\begin_inset CommandInset label
  956
+LatexCommand label
827 957
 name "lst:Using-the-@Type"
828 958
 
829 959
 \end_inset
@@ -836,7 +966,7 @@ Using the @Type annotation
836 966
   @Type{val `type` = "com.foo.jpaweb.model.GenreType"}
837 967
 \end_layout
838 968
 
839  
-\begin_layout Standard
  969
+\begin_layout Plain Layout
840 970
 
841 971
   var genre : Genre.Value = Genre.unknown
842 972
 \end_layout
@@ -851,7 +981,8 @@ Now that we have our objects defined, let's start using them.
851 981
 \end_layout
852 982
 
853 983
 \begin_layout Section
854  
-\begin_inset LatexCommand label
  984
+\begin_inset CommandInset label
  985
+LatexCommand label
855 986
 name "sec:Obtaining-an-EM"
856 987
 
857 988
 \end_inset
@@ -887,15 +1018,19 @@ Fortunately for us, Lift provides just such a mechanism.
887 1018
 \begin_inset Foot
888 1019
 status open
889 1020
 
890  
-\begin_layout Standard
  1021
+\begin_layout Plain Layout
891 1022
 Notably, S.addAround with the LoanWrapper
892 1023
 \end_layout
893 1024
 
894 1025
 \end_inset
895 1026
 
896 1027
 , but for now we're going to focus on just one: the RequestVar
897  
-\begin_inset LatexCommand index
898  
-name "RequestVar"
  1028
+\begin_inset Index
  1029
+status collapsed
  1030
+
  1031
+\begin_layout Plain Layout
  1032
+RequestVar
  1033
+\end_layout
899 1034
 
900 1035
 \end_inset
901 1036
 
@@ -910,7 +1045,7 @@ name "RequestVar"
910 1045
 \begin_inset Note Note
911 1046
 status open
912 1047
 
913  
-\begin_layout Standard
  1048
+\begin_layout Plain Layout
914 1049
 TODO: cross-ref
915 1050
 \end_layout
916 1051
 
@@ -925,13 +1060,15 @@ The initial setup of the entity manager is done through the RequestVar's
925 1060
  constructor.
926 1061
  We define a RequestVar as an object (as opposed to a class) as shown in
927 1062
  listing 
928  
-\begin_inset LatexCommand ref
  1063
+\begin_inset CommandInset ref
  1064
+LatexCommand ref
929 1065
 reference "lst:Setting-up-EM"
930 1066
 
931 1067
 \end_inset
932 1068
 
933 1069
  (the full listing is in section 
934  
-\begin_inset LatexCommand vref
  1070
+\begin_inset CommandInset ref
  1071
+LatexCommand vref
935 1072
 reference "lst:ScalaEntityManager"
936 1073
 
937 1074
 \end_inset
@@ -940,7 +1077,8 @@ reference "lst:ScalaEntityManager"
940 1077
  In our example we're using an abstraction of the EntityManager (and Query)
941 1078
  interfaces as a template for our concrete implementation; we'll cover these
942 1079
  in section 
943  
-\begin_inset LatexCommand vref
  1080
+\begin_inset CommandInset ref
  1081
+LatexCommand vref
944 1082
 reference "sec:ScalaEntityManager-and-ScalaQuery"
945 1083
 
946 1084
 \end_inset
@@ -961,12 +1099,13 @@ lstparams "basicstyle={\scriptsize},breaklines=true,firstline=1,float,frame=sing
961 1099
 inline false
962 1100
 status open
963 1101
 
964  
-\begin_layout Standard
  1102
+\begin_layout Plain Layout
965 1103
 
966 1104
 \begin_inset Caption
967 1105
 
968  
-\begin_layout Standard
969  
-\begin_inset LatexCommand label
  1106
+\begin_layout Plain Layout
  1107
+\begin_inset CommandInset label
  1108
+LatexCommand label
970 1109
 name "lst:Setting-up-EM"
971 1110
 
972 1111
 \end_inset
@@ -979,41 +1118,41 @@ Setting up an EntityManager via RequestVar
979 1118
 
980 1119
 \end_layout
981 1120
 
982  
-\begin_layout Standard
  1121
+\begin_layout Plain Layout
983 1122
 
984 1123
 abstract class ScalaEntityManager(val persistanceName: String) {
985 1124
 \end_layout
986 1125
 
987  
-\begin_layout Standard
  1126
+\begin_layout Plain Layout
988 1127
 
989 1128
   // The concrete impl should provide these methods 
990 1129
 \end_layout
991 1130
 
992  
-\begin_layout Standard
  1131
+\begin_layout Plain Layout
993 1132
 
994 1133
   protected def openEM () : EntityManager 
995 1134
 \end_layout
996 1135
 
997  
-\begin_layout Standard
  1136
+\begin_layout Plain Layout
998 1137
 
999 1138
   protected def closeEM (em : EntityManager)
1000 1139
 \end_layout
1001 1140
 
1002  
-\begin_layout Standard
  1141
+\begin_layout Plain Layout
1003 1142
 
1004 1143
 \end_layout
1005 1144
 
1006  
-\begin_layout Standard
  1145
+\begin_layout Plain Layout
1007 1146
 
1008 1147
   private object emVar extends RequestVar(openEM()) {
1009 1148
 \end_layout
1010 1149
 
1011  
-\begin_layout Standard
  1150
+\begin_layout Plain Layout
1012 1151
 
1013 1152
     override def cleanupFunc : Can[() => Unit]= Full(() => closeEM(this.is))
1014 1153
 \end_layout
1015 1154
 
1016  
-\begin_layout Standard
  1155
+\begin_layout Plain Layout
1017 1156
 
1018 1157
   }
1019 1158
 \end_layout
@@ -1031,8 +1170,12 @@ Now that we've defined the mechanism for setting up and tearing down our
1031 1170
 
1032 1171
 \begin_layout Enumerate
1033 1172
 Construct the EntityManagerFactory
1034  
-\begin_inset LatexCommand index
1035  
-name "EntityManagerFactory"
  1173
+\begin_inset Index
  1174
+status collapsed
  1175
+
  1176
+\begin_layout Plain Layout
  1177
+EntityManagerFactory
  1178
+\end_layout
1036 1179
 
1037 1180
 \end_inset
1038 1181
 
@@ -1041,8 +1184,12 @@ name "EntityManagerFactory"
1041 1184
 
1042 1185
 \begin_layout Enumerate
1043 1186
 Obtain an EntityManager via JNDI
1044  
-\begin_inset LatexCommand index
1045  
-name "JNDI"
  1187
+\begin_inset Index
  1188
+status collapsed
  1189
+
  1190
+\begin_layout Plain Layout
  1191
+JNDI
  1192
+\end_layout
1046 1193
 
1047 1194
 \end_inset
1048 1195
 
@@ -1052,8 +1199,12 @@ name "JNDI"
1052 1199
 \begin_layout Standard
1053 1200
 Of these two, JNDI offers a cleaner approach from the standpoint of deployment.
1054 1201
  Using JNDI acts as a form of IoC
1055  
-\begin_inset LatexCommand index
1056  
-name "Inversion of Control"
  1202
+\begin_inset Index
  1203
+status collapsed
  1204
+
  1205
+\begin_layout Plain Layout
  1206
+Inversion of Control
  1207
+\end_layout
1057 1208
 
1058 1209
 \end_inset
1059 1210
 
@@ -1072,7 +1223,8 @@ Creating a factory directly
1072 1223
 Creating a factory directly is fairly simple, and is the use case for apps
1073 1224
  that will run under the Java SE without access to the JEE facilicities.
1074 1225
  As shown in listing 
1075  
-\begin_inset LatexCommand vref
  1226
+\begin_inset CommandInset ref
  1227
+LatexCommand vref
1076 1228
 reference "lst:Creating-the-EM-directly"
1077 1229
 
1078 1230
 \end_inset
@@ -1104,9 +1256,15 @@ java:comp/env/persistence/<module name>
1104 1256
 \begin_inset Foot
1105 1257
 status open
1106 1258
 
1107  
-\begin_layout Standard
1108  
-\begin_inset LatexCommand htmlurl
1109  
-target "http://database.in2p3.fr/doc/oracle/Oracle_Application_Server_10_Release_3/web.1013/b28221/servjndi010.htm"
  1259
+\begin_layout Plain Layout
  1260
+\begin_inset Flex URL
  1261
+status collapsed
  1262
+
  1263
+\begin_layout Plain Layout
  1264
+
  1265
+http://database.in2p3.fr/doc/oracle/Oracle_Application_Server_10_Release_3/web.1013
  1266
+/b28221/servjndi010.htm
  1267
+\end_layout
1110 1268
 
1111 1269
 \end_inset
1112 1270
 
@@ -1118,7 +1276,8 @@ target "http://database.in2p3.fr/doc/oracle/Oracle_Application_Server_10_Release
1118 1276
 .
1119 1277
  We'll cover how to set up JNDI on lightweight containers like Tomcat and
1120 1278
  Jetty in section 
1121  
-\begin_inset LatexCommand vref
  1279
+\begin_inset CommandInset ref
  1280
+LatexCommand vref
1122 1281
 reference "sec:Setting-up-JNDI-jetty"
1123 1282
 
1124 1283
 \end_inset
@@ -1126,7 +1285,8 @@ reference "sec:Setting-up-JNDI-jetty"
1126 1285
 , but for now we'll concentrate on the client side of things.
1127 1286
  We define our openEM method using the javax.naming.InitialContext class to
1128 1287
  obtain the EM from JNDI, as shown in listing 
1129  
-\begin_inset LatexCommand vref
  1288
+\begin_inset CommandInset ref
  1289
+LatexCommand vref
1130 1290
 reference "lst:EM-Via-JNDI"
1131 1291
 
1132 1292
 \end_inset
@@ -1138,14 +1298,22 @@ reference "lst:EM-Via-JNDI"
1138 1298
  we open begin and end the transaction outsid of the EM's lifecycle.
1139 1299
  In a production application you would want to put these steps into a try/catch
1140 1300
  or use LiftRules.browserResponseToException
1141  
-\begin_inset LatexCommand index
1142  
-name "browserResponseToException"
  1301
+\begin_inset Index
  1302
+status collapsed
  1303
+
  1304
+\begin_layout Plain Layout
  1305
+browserResponseToException
  1306
+\end_layout
1143 1307
 
1144 1308
 \end_inset
1145 1309
 
1146 1310
 
1147  
-\begin_inset LatexCommand index
1148  
-name "LiftRules"
  1311
+\begin_inset Index
  1312
+status collapsed
  1313
+
  1314
+\begin_layout Plain Layout
  1315
+LiftRules
  1316
+\end_layout
1149 1317
 
1150 1318
 \end_inset
1151 1319
 
@@ -1153,7 +1321,7 @@ name "LiftRules"
1153 1321
 \begin_inset Note Note
1154 1322
 status open
1155 1323
 
1156  
-\begin_layout Standard
  1324
+\begin_layout Plain Layout
1157 1325
 TODO: cross-ref
1158 1326
 \end_layout
1159 1327
 
@@ -1179,8 +1347,12 @@ However you obtain the EM, the general principles of how you use the EM
1179 1347
 
1180 1348
 \begin_layout Subsection
1181 1349
 Transactions
1182  
-\begin_inset LatexCommand index
1183  
-name "Transactions"
  1350
+\begin_inset Index
  1351
+status collapsed
  1352
+
  1353
+\begin_layout Plain Layout
  1354
+Transactions
  1355
+\end_layout
1184 1356
 
1185 1357
 \end_inset
1186 1358
 
@@ -1193,9 +1365,14 @@ We're not going to go into too much detail here; there are better documents
1193 1365
 \begin_inset Foot
1194 1366
 status open
1195 1367
 
1196  
-\begin_layout Standard
1197  
-\begin_inset LatexCommand htmlurl
1198  
-target "http://java.sun.com/developer/EJTechTips/2005/tt0125.html"
  1368
+\begin_layout Plain Layout
  1369
+\begin_inset Flex URL
  1370
+status collapsed
  1371
+
  1372
+\begin_layout Plain Layout
  1373
+
  1374
+http://java.sun.com/developer/EJTechTips/2005/tt0125.html
  1375
+\end_layout
1199 1376
 
1200 1377
 \end_inset
1201 1378
 
@@ -1222,7 +1399,8 @@ In JPA, transactions are required.
1222 1399
  JTA.
1223 1400
  Resource local transactions are what you use if you are managing the EM
1224 1401
  factory yourself (section 
1225  
-\begin_inset LatexCommand ref
  1402
+\begin_inset CommandInset ref
  1403
+LatexCommand ref
1226 1404
 reference "lst:Creating-the-EM-directly"
1227 1405
 
1228 1406
 \end_inset
@@ -1232,7 +1410,8 @@ reference "lst:Creating-the-EM-directly"
1232 1410
  Choosing between the two is as simple as setting a property in your persistence.
1233 1411
 xml file (and changing the code to open and close the EM).
1234 1412
  Listing 
1235  
-\begin_inset LatexCommand ref
  1413
+\begin_inset CommandInset ref
  1414
+LatexCommand ref
1236 1415
 reference "lst:Setting-the-transaction-type"
1237 1416
 
1238 1417
 \end_inset
@@ -1259,12 +1438,13 @@ lstparams "basicstyle={\scriptsize},float,frame=single,language=XML"
1259 1438
 inline false
1260 1439
 status open
1261 1440
 
1262  
-\begin_layout Standard
  1441
+\begin_layout Plain Layout
1263 1442
 
1264 1443
 \begin_inset Caption
1265 1444
 
1266  
-\begin_layout Standard
1267  
-\begin_inset LatexCommand label
  1445
+\begin_layout Plain Layout
  1446
+\begin_inset CommandInset label
  1447
+LatexCommand label
1268 1448
 name "lst:Setting-the-transaction-type"
1269 1449
 
1270 1450
 \end_inset
@@ -1277,26 +1457,26 @@ Setting the transaction type
1277 1457
 
1278 1458
 \end_layout
1279 1459
 
1280  
-\begin_layout Standard
  1460
+\begin_layout Plain Layout
1281 1461
 
1282 1462
 <persistence-unit name="jpaweb" transaction-type="RESOURCE_LOCAL">
1283 1463
 \end_layout
1284 1464
 
1285  
-\begin_layout Standard
  1465
+\begin_layout Plain Layout
1286 1466
 
1287 1467
   <non-jta-datasource>myDS</non-jta-datasource>
1288 1468
 \end_layout
1289 1469
 
1290  
-\begin_layout Standard
  1470
+\begin_layout Plain Layout
1291 1471
 
1292 1472
 \end_layout
1293 1473
 
1294  
-\begin_layout Standard
  1474
+\begin_layout Plain Layout
1295 1475
 
1296 1476
 <persistence-unit name="jpaweb" transaction-type="JTA">
1297 1477
 \end_layout
1298 1478
 
1299  
-\begin_layout Standard
  1479
+\begin_layout Plain Layout
1300 1480
 
1301 1481
   <non-jta-datasource>myDS</jta-datasource>
1302 1482
 \end_layout
@@ -1323,7 +1503,8 @@ jta-data-source
1323 1503
 non-jta-datasource
1324 1504
 \family default
1325 1505
  element or you can set the provider properties, as shown in listing 
1326  
-\begin_inset LatexCommand vref
  1506
+\begin_inset CommandInset ref
  1507
+LatexCommand vref
1327 1508
 reference "lst:Setting-resource-local-properties"
1328 1509
 
1329 1510
 \end_inset
@@ -1334,9 +1515,15 @@ reference "lst:Setting-resource-local-properties"
1334 1515
 \begin_inset Foot
1335 1516
 status open
1336 1517
 
1337  
-\begin_layout Standard
1338  
-\begin_inset LatexCommand htmlurl
1339  
-target "http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-extensions.html"
  1518
+\begin_layout Plain Layout
  1519
+\begin_inset Flex URL
  1520
+status collapsed
  1521
+
  1522
+\begin_layout Plain Layout
  1523
+
  1524
+http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/toplink-jpa-e
  1525
+xtensions.html
  1526
+\end_layout
1340 1527
 
1341 1528
 \end_inset
1342 1529
 
@@ -1349,9 +1536,14 @@ target "http://www.oracle.com/technology/products/ias/toplink/JPA/essentials/top
1349 1536
 \begin_inset Foot
1350 1537
 status open
1351 1538
 
1352  
-\begin_layout Standard
1353  
-\begin_inset LatexCommand htmlurl
1354  
-target "http://www.jpox.org/docs/1_2/persistence_unit.html"
  1539
+\begin_layout Plain Layout
  1540
+\begin_inset Flex URL
  1541
+status collapsed
  1542
+
  1543
+\begin_layout Plain Layout
  1544
+
  1545
+http://www.jpox.org/docs/1_2/persistence_unit.html
  1546
+\end_layout
1355 1547
 
1356 1548
 \end_inset
1357 1549
 
@@ -1381,12 +1573,13 @@ lstparams "basicstyle={\scriptsize},breaklines=true,float,frame=single,language=
1381 1573
 inline false
1382 1574
 status open
1383 1575
 
1384  
-\begin_layout Standard
  1576
+\begin_layout Plain Layout
1385 1577
 
1386 1578
 \begin_inset Caption
1387 1579
 
1388  
-\begin_layout Standard
1389  
-\begin_inset LatexCommand label
  1580
+\begin_layout Plain Layout
  1581
+\begin_inset CommandInset label
  1582
+LatexCommand label
1390 1583
 name "lst:Setting-resource-local-properties"
1391 1584
 
1392 1585
 \end_inset
@@ -1399,60 +1592,60 @@ Setting resource-local properties for Hibernate
1399 1592
 
1400 1593
 \end_layout
1401 1594
 
1402  
-\begin_layout Standard
  1595
+\begin_layout Plain Layout
1403 1596
 
1404 1597
 <persistence>
1405 1598
 \end_layout
1406 1599
 
1407  
-\begin_layout Standard
  1600
+\begin_layout Plain Layout
1408 1601
 
1409 1602
    <persistence-unit name="jpaweb" transaction-type="RESOURCE_LOCAL">
1410 1603
 \end_layout
1411 1604
 
1412  
-\begin_layout Standard
  1605
+\begin_layout Plain Layout
1413 1606
 
1414 1607
       <properties>
1415 1608
 \end_layout
1416 1609
 
1417  
-\begin_layout Standard
  1610
+\begin_layout Plain Layout
1418 1611
 
1419 1612
          <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLD
1420 1613
 ialect"/>
1421 1614
 \end_layout
1422 1615
 
1423  
-\begin_layout Standard
  1616
+\begin_layout Plain Layout
1424 1617
 
1425 1618
          <property name="hibernate.connection.driver_class" value="org.postgresql.Dr
1426 1619
 iver"/>
1427 1620
 \end_layout
1428 1621
 
1429  
-\begin_layout Standard
  1622
+\begin_layout Plain Layout
1430 1623
 
1431 1624
          <property name="hibernate.connection.username" value="somUser"/>
1432 1625
 \end_layout
1433 1626
 
1434  
-\begin_layout Standard
  1627
+\begin_layout Plain Layout
1435 1628
 
1436 1629
          <property name="hibernate.connection.password" value="somePass"/>
1437 1630
 \end_layout
1438 1631
 
1439  
-\begin_layout Standard
  1632
+\begin_layout Plain Layout
1440 1633
 
1441 1634
          <property name="hibernate.connection.url" value="jdbc:postgresql:jpaweb"/
1442 1635
 >
1443 1636
 \end_layout
1444 1637
 
1445  
-\begin_layout Standard
  1638
+\begin_layout Plain Layout
1446 1639
 
1447 1640
       </properties>
1448 1641
 \end_layout
1449 1642
 
1450  
-\begin_layout Standard
  1643
+\begin_layout Plain Layout
1451 1644
 
1452 1645
    </persistence-unit>
1453 1646
 \end_layout
1454 1647
 
1455  
-\begin_layout Standard
  1648
+\begin_layout Plain Layout
1456 1649
 
1457 1650
 </persistence>
1458 1651
 \end_layout
@@ -1477,7 +1670,8 @@ javax.persistence.NonUniqueResultException
1477 1670
 \end_layout
1478 1671
 
1479 1672
 \begin_layout Section