【文章內(nèi)容簡介】
A if any of the terms we’ve mentioned are new or knowledge is mandatory for sound Java database application you need more material, get a copy of the excellent book SQL Tuning by Dan Tow Also read An Introduction to Database Systems [Date 2020] for the theory, concepts, and ideals of (relational) database systems. Although the relational database is one part of ORM, the other part, of course, consists of the objects in your Java application that need to be persisted to the database using SQL. Using SQL in Java When you work with an SQL database in a Java application, the Java code issues SQL statements to the database via the Java DataBase Connectivity (JDBC) API. The SQL itself might have been written by hand and embedded in the Java code, or it might have been generated on the fly by Java code. You use the JDBC API to bind arguments to query parameters, initiate execution of the query, scroll through the query result table, retrieve values from the result set, and so on. These are lowlevel data access tasks。 as application developers, we’re more interested in the business problem that requires this data access. It isn’t clear that we should be concerning ourselves with such tedious, mechanical we’d really like to be able to do is write code that saves and retrieves plex objects—the instances of our classes—to and from the database, relieving us of this lowlevel the data access tasks are often so tedious, we have to ask: Are the relational data model and (especially) SQL the right choices for persistence in objectoriented applications? We answer this question immediately: Yes! There are many reasons why SQL databases dominate the puting industry. Relational database management systems are the only proven data management technology and are almost always a requirement in any Java , for the last 15 years, developers have spoken of a paradigm mismatch explains why so much effort is expended on persistencerelated concerns in every enterprise project. The paradigms referred to are object modeling and relational modeling, or perhaps objectoriented programming and SQL. Let’s begin our exploration of the mismatch problem by asking what persistence means in the context of objectoriented application development. First we’ll widen the simplistic definition of persistence stated at the beginning of this section to a broader, more mature understanding of what is involved in maintaining and using persistent data. Persistence in objectoriented applications In an objectoriented application, 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 recreated at some point in the application isn’t limited to single objects—entire graphs of interconnected objects may be made persistent and later recreated in a new process. Most objects aren’t persistent。 a transient object has a limited lifetime that is bounded by the life of the process that instantiated it. Almost all Java applications contain a mix of persistent and transient objects。 hence we need a subsystem that manages our persistent relational databases provide a structured representation of persistent data, enabling sorting, searching, and aggregation of data. Database management systems are responsible for managing concurrency and data integrity。 they’re responsible for sharing data between multiple users and multiple applications. A database management system also provides datalevel securi