Skip to content
Snippets Groups Projects
Commit 052cd97a authored by Goik Martin's avatar Goik Martin
Browse files

persistence illustration

parent d8830b61
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@
FIGFILES=booknavigate clientserv contentmixed cpp crossmedia dictionaryStack \
entityresolve externalize filtering headfoot heartland jdbcarch jdbcFourTier \
persistence \
jdbcObjectRelation jdbcread jdbcReadWrite jdbcSniffing jdbcThreeTier \
jdbcurl memofour memorelativexpath memotree memoxpath overlay pagerefhyperStack \
pagerefStack pageStack persistHandlerStates preceding regions saxxmlrdbms sqlinject \
......
#FIG 3.2 Produced by xfig version 3.2.5b
Landscape
Center
Metric
A4
100.00
Single
-2
1200 2
0 32 #fffffe
0 33 #c6b797
0 34 #dccba6
0 35 #404040
0 36 #808080
0 37 #c0c0c0
0 38 #e0e0e0
0 39 #8e8f8e
0 40 #aaaaaa
0 41 #555555
0 42 #eff8ff
0 43 #8e8e8e
0 44 #d7d7d7
0 45 #aeaeae
0 46 #bebebe
0 47 #515151
0 48 #e7e3e7
0 49 #000049
0 50 #797979
0 51 #303430
0 52 #414141
0 53 #c7b696
0 54 #414541
0 55 #9c0000
0 56 #8c8c8c
0 57 #424242
0 58 #8c8c8c
0 59 #424242
0 60 #8c8c8c
0 61 #424242
0 62 #8c8c8c
0 63 #424242
0 64 #8c8c8c
0 65 #424242
0 66 #8c8c8c
0 67 #424242
5 1 0 2 -1 7 690 -1 -1 0.000 0 1 0 0 6423.465 2372.779 5580 3555 6435 3825 7200 3600
5 1 0 2 -1 7 690 -1 -1 0.000 0 1 0 0 6423.465 1472.779 5580 2655 6435 2925 7200 2700
6 5805 840 6600 1260
4 0 -1 560 -1 30 16 0.0000 4 195 750 5805 1035 termi-\001
4 0 -1 560 -1 30 16 0.0000 4 195 795 5805 1260 nation\001
-6
6 6825 435 7305 915
1 3 0 2 -1 0 560 -1 -1 0.000 1 0.0000 7065 675 225 225 7065 675 7200 855
1 3 0 2 -1 0 560 -1 20 0.000 1 0.0000 7065 675 142 142 7065 675 7200 720
-6
6 5805 5790 6600 6210
4 0 -1 480 -1 30 16 0.0000 4 195 750 5805 5985 termi-\001
4 0 -1 480 -1 30 16 0.0000 4 195 795 5805 6210 nation\001
-6
6 6825 5385 7305 5865
1 3 0 2 -1 0 480 -1 -1 0.000 1 0.0000 7065 5625 225 225 7065 5625 7200 5805
1 3 0 2 -1 0 480 -1 20 0.000 1 0.0000 7065 5625 142 142 7065 5625 7200 5670
-6
1 1 0 2 -1 0 680 -1 2 0.000 1 0.0000 3735 720 1980 675 3735 720 5715 720
1 1 0 2 -1 0 540 -1 2 0.000 1 0.0000 3735 5670 1980 675 3735 5670 5715 5670
1 1 0 2 -1 7 690 -1 -1 0.000 1 0.0000 6398 2513 810 315 6398 2513 7208 2828
2 1 0 2 -1 7 680 -1 -1 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
495 675 1755 675
2 1 0 2 -1 7 640 -1 -1 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
2520 675 3555 675
2 1 0 2 4 7 640 -1 -1 0.000 0 0 -1 0 0 2
3645 495 4635 495
2 1 0 2 4 7 640 -1 -1 0.000 0 0 -1 0 0 2
3645 1125 4635 1125
2 4 0 2 4 7 640 -1 -1 0.000 0 0 7 0 0 5
4635 1260 4635 225 3645 225 3645 1260 4635 1260
2 1 0 2 4 4 580 -1 20 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
4185 1260 5670 2295
2 1 0 2 -1 7 560 -1 -1 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
5715 675 6840 675
2 2 0 2 7 7 700 -1 -1 0.000 0 0 -1 0 0 5
0 0 10800 0 10800 6750 0 6750 0 0
2 1 0 2 -1 7 540 -1 -1 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
495 5625 1755 5625
2 1 0 2 -1 7 520 -1 -1 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
2520 5625 3555 5625
2 4 0 2 4 7 520 -1 -1 0.000 0 0 7 0 0 5
4635 6210 4635 5175 3645 5175 3645 6210 4635 6210
2 1 0 2 4 7 520 -1 -1 0.000 0 0 -1 0 0 2
3645 5445 4635 5445
2 1 0 2 4 7 520 -1 -1 0.000 0 0 -1 0 0 2
3645 6075 4635 6075
2 1 0 2 -1 7 480 -1 -1 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
5715 5625 6840 5625
2 1 0 2 4 4 500 -1 20 0.000 0 0 -1 1 0 2
2 1 2.00 120.00 240.00
6705 3555 4635 5760
2 1 0 2 -1 7 690 -1 -1 0.000 0 0 -1 0 0 2
7200 2535 7200 3600
2 1 0 2 -1 7 690 -1 -1 0.000 0 0 -1 0 0 2
5580 2490 5580 3555
4 0 -1 700 -1 30 16 0.0000 4 180 390 0 810 OS\001
4 0 -1 680 -1 30 16 0.0000 4 210 930 720 405 spawns\001
4 0 -1 660 -1 30 16 0.0000 4 240 615 1845 720 Java-\001
4 0 -1 660 -1 30 16 0.0000 4 210 465 1935 900 app\001
4 0 -1 640 -1 30 16 0.0000 4 180 840 2565 990 creates\001
4 0 4 640 -1 30 16 0.0000 4 180 570 3780 450 User\001
4 0 4 620 -1 30 16 0.0000 4 255 870 3690 765 Joe Bix\001
4 0 4 600 -1 30 16 0.0000 4 195 390 3690 1080 bix\001
4 0 -1 540 -1 30 16 0.0000 4 210 930 720 5355 spawns\001
4 0 -1 540 -1 30 16 0.0000 4 180 390 0 5760 OS\001
4 0 -1 520 -1 30 16 0.0000 4 240 615 1845 5670 Java-\001
4 0 -1 520 -1 30 16 0.0000 4 210 465 1935 5850 app\001
4 0 -1 520 -1 30 16 0.0000 4 180 840 2565 5940 creates\001
4 0 4 520 -1 30 16 0.0000 4 180 570 3780 5400 User\001
4 0 4 500 -1 30 16 0.0000 4 255 870 3690 5715 Joe Bix\001
4 0 4 500 -1 30 16 0.0000 4 195 390 3690 6030 bix\001
4 0 -1 550 -1 30 16 0.0000 4 195 1845 8325 765 Transient Data\001
4 0 -1 460 -1 30 16 0.0000 4 195 1845 8325 5715 Transient Data\001
4 0 -1 570 -1 30 16 0.0000 4 195 1875 8325 3015 Persistent Data\001
4 0 4 580 -1 30 16 5.7596 4 135 540 4815 1665 save\001
4 0 4 500 -1 30 16 0.7679 4 180 540 5220 5040 load\001
4 0 -1 560 -1 30 16 0.0000 4 270 330 5850 540 jre\001
4 0 -1 480 -1 30 16 0.0000 4 270 330 5850 5490 jre\001
4 0 -1 680 -1 30 16 0.0000 4 270 540 765 1035 jre 1\001
4 0 -1 540 -1 30 16 0.0000 4 270 540 765 5985 jre 2\001
4 0 -1 690 -1 30 16 0.0000 4 180 1035 5985 3240 RDBMS\001
4 0 4 580 -1 30 16 0.0000 4 255 1515 5625 3510 (Joe Bix,bix)\001
......@@ -620,6 +620,63 @@ drwxr-xr-x 4 goik fb1prof 4096 Nov 8 22:04 ..
<chapter xml:id="intro">
<title>Accessing Relational Data</title>
 
<section xml:id="persistence">
<title>Persistence in Object Oriented languages</title>
<para>Following <xref linkend="Bauer05"/> we may define persistence
by:</para>
<blockquote>
<para>persistence allows an object to outlive the process that
created it. The state of the object may be stored to disk and an
object with the same state re-created at some point in the
future.</para>
</blockquote>
<para>The notion of <quote>process</quote> refers to operating
systems. Let us start wit a simple example assuming a Java class
User:</para>
<programlisting>public class User {
String cname; //The user's common name e.g. 'Joe Bix'
String uid; //The user's unique system user ID (login) e.g. 'bix'
// getters, setters and other stuff
...
}</programlisting>
<para>A relational implementation might look like:</para>
<programlisting>CREATE TABLE User(
CHAR(80) cname
,CHAR(10) uid PRIMARY KEY
)</programlisting>
<para>Now a Java application may create instances of class
<code>User</code> and save these to a database: </para>
<figure xml:id="processObjPersist">
<title>Persistence across process boundaries</title>
<mediaobject>
<imageobject>
<imagedata fileref="Ref/Fig/persistence.fig"/>
</imageobject>
</mediaobject>
</figure>
<para>Both the jre instances and the RDBMS database server are
processes (or sets of processes) typically existing in different
address spaces. The two jre processes mentioned here may as well be
started in disjoint address spaces. In fact we might even run two
entirely different applications implemented in other languages like
<acronym>Php</acronym>.</para>
<para>It is important to mention that the two safe and load arrows
thus typically denote a communication across machine
boundaries.</para>
</section>
<section xml:id="jdbcIntro">
<title>Introduction to <trademark
xlink:href="http://electronics.zibb.com/trademark/jdbc/29545026">JDBC</trademark></title>
......@@ -991,25 +1048,41 @@ drwxr-xr-x 4 goik fb1prof 4096 Nov 8 22:04 ..
 
<programlisting>Successfully inserted 1 dataset(s)</programlisting>
 
<para>However a second invocation yields:</para>
<qandaset role="exercise">
<qandadiv>
<qandaentry>
<question>
<para>A second invocation of
<classname>sda.jdbc.intro.v1.SimpleInsert</classname> yields
the following runtime error:</para>
 
<programlisting>Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
<programlisting>Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
<emphasis role="bold">Duplicate entry 'jim@foo.org' for key 'email'</emphasis>
...
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1617)
at sda.jdbc.intro.SimpleInsert.main(SimpleInsert.java:17)</programlisting>
</question>
 
<para>This (expected) error is easy to understand: The exception's
message text <emphasis role="bold">Duplicate entry 'Jim' for key
'PRIMARY'</emphasis> informs us about a UNIQUE key constraint
violation with respect to our schema definition in <xref
linkend="figSchemaPerson"/>.</para>
<answer>
<para>This expected error is easy to understand: The
exception's message text <emphasis role="bold">Duplicate
entry 'Jim' for key 'PRIMARY'</emphasis> informs us about a
UNIQUE key constraint violation with respect to the
attribute <code>email</code> in our schema definition in
<xref linkend="figSchemaPerson"/>. We cannot add a second
entry with the same value <code>'jim@foo.org'</code>.</para>
</answer>
</qandaentry>
</qandadiv>
</qandaset>
 
<para>It is worth to mention that the
<productname>Mysql</productname> driver implementation does not have
to be available at compile time. On the other hand when working with
eclipse we need a separate runtime configuration for each runnable
<trademark
to be available at compile time. JDBC uses interfaces in favour of
concrete class. Only at runtime we do need concrete classes.</para>
<para>On the other hand when working with eclipse we need a separate
runtime configuration for each runnable <trademark
xlink:href="http://www.oracle.com/us/legal/third-party-trademarks/index.html">Java</trademark>
application. This becomes tedious after some time. So you may want
to follow the author and just add
......@@ -14871,8 +14944,8 @@ leader-pattern="dots"/&gt;C&lt;fo:leader leader-pattern="dots"/&gt;D&lt;/fo:bloc
<part>
<title>Structured Data and Applications 2</title>
 
<chapter xml:id="XXX">
<title>XXX</title>
<chapter xml:id="orm">
<title>Object Relational Mapping</title>
 
<para>XYZ</para>
</chapter>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment