Skip to main content

2016 | OriginalPaper | Buchkapitel

3. Building a Simple Application

verfasst von : Joseph B. Ottinger, Jeff Linwood, Dave Minter

Erschienen in: Beginning Hibernate

Verlag: Apress

Aktivieren Sie unsere intelligente Suche, um passende Fachinhalte oder Patente zu finden.

search-config
loading …

Abstract

In this chapter, we're going to create the shell of an application, which will allow us to demonstrate a number of concepts common for systems that use Hibernate. We'll be covering the following.

Sie haben noch keine Lizenz? Dann Informieren Sie sich jetzt über unsere Produkte:

Springer Professional "Wirtschaft+Technik"

Online-Abonnement

Mit Springer Professional "Wirtschaft+Technik" erhalten Sie Zugriff auf:

  • über 102.000 Bücher
  • über 537 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Maschinenbau + Werkstoffe
  • Versicherung + Risiko

Jetzt Wissensvorsprung sichern!

Springer Professional "Technik"

Online-Abonnement

Mit Springer Professional "Technik" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 390 Zeitschriften

aus folgenden Fachgebieten:

  • Automobil + Motoren
  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Elektrotechnik + Elektronik
  • Energie + Nachhaltigkeit
  • Maschinenbau + Werkstoffe




 

Jetzt Wissensvorsprung sichern!

Springer Professional "Wirtschaft"

Online-Abonnement

Mit Springer Professional "Wirtschaft" erhalten Sie Zugriff auf:

  • über 67.000 Bücher
  • über 340 Zeitschriften

aus folgenden Fachgebieten:

  • Bauwesen + Immobilien
  • Business IT + Informatik
  • Finance + Banking
  • Management + Führung
  • Marketing + Vertrieb
  • Versicherung + Risiko




Jetzt Wissensvorsprung sichern!

Fußnoten
1
This seems almost logical.
 
2
This is a new feature for Hibernate 5, and it’s much appreciated.
 
3
We can let the database generate the average, instead of letting the Java 8 stream facility calculate it for us, which is also pretty easy. However, doing it in the database avoids the transfer of data from the database to our code, which can save a lot of time and, potentially, network traffic. Generally, doing it with the database is better, and as we’ll see, it’s pretty easy as well.
 
4
It generally does this by using a proxied object. When you change the data values in the object, the proxy records the change so that the transaction knows to write the data to the database on transaction commit. If this sounds like magic, it’s not – but it’s also not trivial to do. Appreciate Hibernate’s authors.
 
5
We'll be revisiting this topic in more detail in Chapter 4.
 
6
We’re going to be revisiting transactions quite a bit in Chapter 4.
 
7
Note that Hibernate has validation facilities that make this sort of thing very easy to do; the way this is described here is rather unglamorous.
 
8
Of course, you could also just use the raw JPA interface. However, it’s much more limited than the Hibernate API.
 
9
Note that Spring has its own ways to manage Hibernate Session references; using this in a Spring application would be ill-advised.
 
10
How could we address it? Not very easily, that's how. We could try to add semantic roles to each attribute – for example, we could mark Drew Lombardo as an observer, and J. C. Smell as a subject. If we used a subject where an observer was expected, then we could programmatically indicate an error condition. However, that doesn't help if Drew is an observer and a subject – which is likely to be a normal case.
 
11
One possibility for checking for side effects might be clearing the entire dataset (as we did in the RankingTest code, by closing the SessionFactory down every test), then clearing the data we expected to write and looking for any extraneous data. There are certainly other possibilities, but all of these are out of our scope here.
 
12
Pretty much everyone who knows SQL moderately well has probably been fuming about how we're pulling data from the database. That’s okay – the way it’s being done here is pretty lame.
 
13
Even with an embedded database, though, it can be faster; an embedded database can use internal access to the data to which our application code normally has no access, even before we consider the possibility of efficient queries through the use of indexes.
 
Metadaten
Titel
Building a Simple Application
verfasst von
Joseph B. Ottinger
Jeff Linwood
Dave Minter
Copyright-Jahr
2016
Verlag
Apress
DOI
https://doi.org/10.1007/978-1-4842-2319-2_3