Introduction Flashcards

1
Q

Java Persistence 2.2 Maintenance release statement

A

The Java Persistence 2.2 specification enhances the Java Persistence API with support for repeating annotations; injection into attribute converters; support
for mapping of the java.time.LocalDate, java.time.LocalTime, java.time.
LocalDateTime, java.time.OffsetTime, and ava.time.OffsetDateTime types; and methods to retrieve the results of Query and TypedQuery as streams.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Definition of ORM

A

The technique of bridging the gap between the object model and the relational model is known as object-relational mapping, often referred to as O-R mapping or simply ORM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

why object-relational mapping?

A
  1. Objects, not tables: Applications should be written in terms of the domain model, not bound to the relational model. It must be possible to operate on and query against the domain model without
    having to express it in the relational language of tables, columns, and foreign keys.
  2. Convenience, not ignorance: It is meant for those who have an understanding of the issues and know what they need, but who don’t want to have to write thousands of lines of code to deal with a problem that has already been solved.
  3. Unobtrusive, not transparent: It is unreasonable to expect that persistence be transparent because an application always needs to have control of the objects that it is persisting and be aware of the
    entity lifecycle.
  4. Legacy data, new objects: It is far more likely that an application will target an existing relational database schema than create a new one. Support for legacy schemas is one of the most relevant use cases that will arise, and it is quite possible that such databases will outlive every one of us.
  5. Enough, but not too much: Enterprise developers have problems to solve, and they need features sufficient to solve those problems. What they don’t like is being forced to eat a heavyweight persistence model that introduces large overhead because it is solving problems that
    many do not even agree are problems.
  6. Local, but mobile: A persistent representation of data does not need to be modeled as a full-fledged remote object. Distribution is something that exists as part of the application, not part of the
    persistence layer. The entities that contain the persistent state, however, must be able to travel to whichever layer needs them so that if an application is distributed, then the entities will support and not inhibit a particular architecture.
  7. Standard API, with pluggable implementations: Large companies with sizable applications don’t want to risk being coupled to product-specific libraries and interfaces. By depending only on defined
    standard interfaces, the application is decoupled from proprietary APIs and can switch implementations if another becomes more suitable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Main challenge of ORM

A

the challenge in object-relational mapping is not so much the complexity of a single mapping but that there are so many possible mappings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Samples for non mapping issues

A
  • Because database schemas are much harder to change, should the class be forced to adopt the same storage strategy in order to remain consistent with the relational model?
  • there are usually many applications, some object-oriented and some based on Structured Query Language (SQL), that retrieve from and store data into a single database. The dependency of multiple applications on the same database means that changing the database would affect every one of the applications, clearly an undesirable and potentially expensive option. It’s up to the object model to adapt and find ways to work with the database schema without letting the physical design overpower the logical application model.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The Java Persistence API consists of four areas

A
  • The Java Persistence API
  • The Java Persistence Criteria API
  • The Query language
  • Object-relational mapping metadata
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

ORM is older than Java itself

A

It may come as a surprise to learn that object-relational mapping solutions have been around for a long time; longer even than the Java language itself.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Two popular persistence APis at early days

A

The two most popular proprietary persistence APIs were TopLink in the commercial space and Hibernate in the open source community.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

major advantage and disadvantage of data mappers

A

The biggest advantage of using a data mapping strategy like MyBatis is that the application has complete control over the SQL that is sent to the database. Stored procedures and all of the SQL features available from the driver are all fair game, and the overhead added by the framework is smaller than when using a full-blown ORM framework.

the major disadvantage of being able to write custom SQL is that it has to be maintained. Any changes made to the object model can have repercussions on the data model and possibly cause significant SQL churn during development. A minimalist framework also opens the door for the developer to create new features as the application requirements grow, eventually leading to a reinvention of the ORM wheel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What was Java Data Objects (JDO)?

A

Java Data Objects (JDO) was inspired and supported primarily by the object-oriented database (OODB) vendors and never really got adopted by the mainstream programming community. It required vendors to enhance the bytecode of domain objects to produce class files that were binary-compatible across all vendors, and every compliant vendor’s products had to be capable of producing and consuming them. JDO also had a query language that was decidedly object-oriented in nature, which did not sit well with relational database users, who were in an overwhelming majority.

Few supported the specification, so JDO was talked about, but rarely used.

Sun announced that JDO would be reduced to specification maintenance mode and that JPA would draw from both JDO and the persistence vendors
and become the single supported standard going forward.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

why not even just standardize on an open source product like Hibernate?

A

Binding a standard to an open source project like ibernate would be problematic for the standard and probably even worse for the Hibernate project.

Standardization might not be valued by the consultant or the five-person software shop, to a corporation it is huge. Software technologies are a big investment for most corporate IT departments, and risk must be measured when large sums of money are involved.

Besides portability, the value of standardizing a technology is manifested in all sorts of other areas as well. Education, design patterns, and industry communication are just some of the many benefits that tandards bring to the table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The Java Persistence API

A
  • The Java Persistence API is a lightweight, POJO-based framework for Java persistence.
  • JPA is not a product but just a specification that cannot perform persistence by itself.
  • JPA of course requires a database to persist to.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

EJB 3.0 and JPA 1.0

A

released in 2006, ended up being divided into three distinct pieces and split across three separate documents.

  • The first document contained all of the legacy EJB component model content.
  • The second one described the new simplified POJO component model.
  • The third was the Java Persistence API, a stand-alone specification that described the persistence model in both the Java SE and Java EE environments.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

JPA 2.0

A

The next release, JPA 2.0, went final in 2009.
New features included:
* Additional mapping capabilities
* Flexible ways to determine the way the provider accessed the entity state
* Extensions to the Java Persistence Query Language (JPQL)
* Probably the most significant feature was the Java Criteria API, a programmatic way to create dynamic queries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

JPA 2.1

A

The release of JPA 2.1 was in 2013.
The JPA 2.1 specification added:
* Mapping converters
* Stored procedure support
* Unsynchronized persistence contexts for improved conversational operations.
* It also added the ability to create entity graphs and pass them to queries, amounting to what are commonly known as fetch group constraints on the returned object set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

JPA 2.2

A

JPA 2.2 maintenance release was published by Oracle in June 2017.

  • Ability to stream the result of a query execution
  • @Repeatable for all relevant annotations
  • Support for basic Java 8 Date and Time types
  • Allowing AttributeConverters to support CDI injection
  • Updating the persistence provider discovery mechanism
  • Allowing all JPA annotations to be used in meta-annotations