Hibernate: a developer Notebook Chapter 1

xiaoxiao2021-03-06  39

Chapter 1 Installation and Settings

prompt:

In this chapter, these contents:

Get an ANT distribution

Get HSQLDB database engine

Get hibernate

Set an engineering hierarchy

There are so many great, free, open source Java TM tools are constantly amazing. I had to build my own tool when I need a lightweight object / relationship mapping service for a JSP e-commerce project. It spent a few years, developed some cool and unique features, and then we used it in a lot of different environments. But now I found Hibernate, I expect that I can use it in my next project to replace the system I am familiar with. This should be able to tell you how much it is.

Since you see this book, your attention will be attracted to a strong and convenient way to bridge between Java objects and relational databases. Hibernate acts as this role, did not make it very complicated to learn it as a challenge of making people fear. In order to prove this, this chapter will guide you to the use of Hibernate and can personally see how exciting.

1.1 Get an ANT distribution

If you haven't used Ant to manage build, test, run, and package your Java project, now it's time. The example of this book is driven by Ant, so you need a working Ant installation to follow and experience a variety of changes in your own system, this is the best way to learn.

First, get an ANT binary release and install it.

1.1.1

Why do I want it?

We choose Ant to construct our example for several reasons. It is convenient and powerful, it is based on the growing (almost ubiquitous) standard build tool based on Java development, which is free and cross-platform. Many current Hibernate releases samples and assistants are a Windows batch file, which is not beneficial to those who live in the UNIX world like me. Using Ant means that our example can run as the same place with a Java environment, that is, we don't have to make any readers of this book feel discouraged and distressed. Happy is that it also means that we can do more cool things with less efforts - especially since several Hibernate tools have clear ANT support, we will demonstrate how to achieve the purpose.

In order to take advantage of all of these features, you need to install Ant on your system and make it work.

prompt:

I often curious why people can worry about ANT with make. Now I have seen how good it is to manage Java, and I will feel lost.

1.1.2

what should I do?

Download an Ant binary release version from ant.apache.org/binddalogload.cgi. Scroll the page until you find the current ANT release version, then download a file that you use the convenient format. Choose a place to stay in it and then expand the archive file there. The directory you expand the archive file will be referenced as an ANT_HOME environment variable. That is to say, if you have already expanded the archive file in / usr / local / apache-Ant-

1.5.1

In the directory, you might want to create a symbolic link to make it easier, and you can avoid changing the environment variable configuration when you upgrade to a new version.

/ usr / local $ ln -s apache-Ant-

1.5.1 a

NT

Once Ant is installed, you need to do something make it work normally. You need to add Ant's bin directory (in our example is / user / local / Ant / bin) to your command path (PATH environment variable). You also need to set the ANT_HOME environment variable to the top layer of the installation directory (in this example / user / local / Ant). Different operations

Detailed description of how these steps in the system can be found in the ANT manual, ant.apache.org / manual / if you need. Of course, we also assume that you have got Java SDK. Because some Hibernate features are only available under Java 1.4, you'd better upgrade to the latest 1.4 SDK. Most Hibernate can be used in Java 1.3, but you have to use your 1.3 compiler to reconstruct the Hibernate's JAR file. Our example is assumed that you are written with Java 1.4, if you have no, these examples require some changes.

Once these things are set, you should be able to test the running Ant to check all things work Normal:

~ $ ANT -VERSION

Apache Ant Version

1.5.1

Compiled on February 7 2003

1.1.3

What happened?

In fact, there is not much thing, but you are now in a location that can be tested in the following examples, and you can use them as the starting point of your actual Hibernate project.

If you are an Ant's newbie, read the manual to get it how to work and what you can do for you is also a good note. This will help you get a clear us in an example.

The meaning of the build.xml file. If you decide to like Ant and want to be a master, you can pick up O'REILLY's Ant: The Definitive Guide this book (of course, after you have read this book)!

1.1.4

on...

... eclipse, java Ant, so you can start directly, and some may need you skip some obstacles). If all of this does not pass, you can use IDE to develop your own code, but you have to perform these build scripts from the command line.

转载请注明原文地址:https://www.9cbs.com/read-77001.html

New Post(0)