Wiley 978-0-7645-7677-5 Datenblatt

Stöbern Sie online oder laden Sie Datenblatt nach Software-Handbücher Wiley 978-0-7645-7677-5 herunter. Wiley Professional Hibernate Benutzerhandbuch

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 14
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 0
Introduction to Mapping
Objects to Relational
Databases
In the computer industry, we commonly have discussions, disagreements, and even shouting
matches over which of the latest languages are the best and where they should be used.
Discussions turn to the best platform currently available and who’s suing whom. However, each
of us is also thinking about the latest project we’ve been given and its strict deadline. Overall, the
project isn’t complex, but we have to support numerous database backend systems. This means
we need to incorporate a persistence layer to handle the database differences. That part isn’t too
difficult, but what about the data itself? Do we just store it in some proprietary database and deal
with the details later? No, we need to have a strategy that works with our application and the lan-
guage the application is written in.
Today’s programming languages take advantage of the latest in object-oriented techniques. As you
know, an object is a construct to enforce encapsulation. The problem is how to store an object for
use by the same application at a later time or by another application. Some of the common solu-
tions to this problem are:
Serialization
XML
Object-oriented database systems mapping
Let’s consider these possible solutions and determine their advantages and disadvantage before
looking at the solution around which this book is written.
1
11
03_576771_c01.qxd 9/1/04 12:09 PM Page 1
COPYRIGHTED MATERIAL
Seitenansicht 0
1 2 3 4 5 6 ... 13 14

Inhaltsverzeichnis

Seite 1 - COPYRIGHTED MATERIAL

Introduction to MappingObjects to RelationalDatabasesIn the computer industry, we commonly have discussions, disagreements, and even shoutingmatches o

Seite 2 - Serialization

newFeatures and count columns need to be populated with a value such as null. But will this work?Can’t we have a SpecialEditionCD object where both th

Seite 3

created. Maintaining these relationships can be complex, depending on the hierarchy being mapped. Wearen’t wasting database space if we have a CD obje

Seite 4

To map the relationship shown in Figure 1.5 to a relational database, we need to use a foreign key thatassociates the owner with the account. Since th

Seite 5

Figure 1.6As you can see, the foreign key, account_id, is used in the mapping just as it is in the one-to-one rela-tionship map. When an account is ad

Seite 6

14Chapter 1cost int,accounts int);create table account_security (ID int not null primary key auto_increment,account_id int,security_id int,);Figure 1.

Seite 7

SerializationYou can save data stored in an object by creating a flat-file representation of the object. In the Java lan-guage, this process is called

Seite 8 - Handling Inheritance

create table cd (title varchar,artist varchar);From the XML, we can easily build a class like this:public class cd {String title;String artist;}Having

Seite 9

class has two attributes that would need to be mapped to a relational database table for permanent stor-age. The title and artist fields can be mapped

Seite 10 - Chapter 1

ArrayList tracks;public CD(String title, String artist) { this.title = title;this.artist = artist;tracks = new ArrayListO;}public void addTrack(String

Seite 11 - Working With Relationships

If we have another CD to store, should another track table be added to the system, or should the tracksbe added to the existing CD_tracks table? If we

Seite 12

Our CD class can be further complicated by adding an attribute based on another class type. For example:public class CD implements Serializable { Stri

Seite 13

Primary Keys, Timestamps, and Version NumbersIn the examples presented so far, all the database tables have included a primary key that isn’t part oft

Seite 14

❑ Create a single table using the attributes from the lowest child.❑ Create a table per class.❑ Create a table per concrete class.Let’s consider each

Kommentare zu diesen Handbüchern

Keine Kommentare