Web hosting isp - CHAPTER 2 Starting a project Hello World application
CHAPTER 2 Starting a project Hello World application and extend it with more functionality. You can, for example, try different HQL queries or logging options. Don t forget that your database system is still running in the background, and that you have to either export a fresh schema or stop it and delete the database files to get a clean and empty database again. In the next section, we walk through the Hello World example again, with Java Persistence interfaces and EJB 3.0. 2.2 Starting a Java Persistence project In the following sections, we show you some of the advantages of JPA and the new EJB 3.0 standard, and how annotations and the standardized programming interfaces can simplify application development, even when compared with Hibernate. Obviously, designing and linking to standardized interfaces is an advantage if you ever need to port or deploy an application on a different runtime environment. Besides portability, though, there are many good reasons to give JPA a closer look. We ll now guide you through another Hello World example, this time with Hibernate Annotations and Hibernate EntityManager. You ll reuse the basic project infrastructure introduced in the previous section so you can see where JPA differs from Hibernate. After working with annotations and the JPA interfaces, we ll show how an application integrates and interacts with other managed components EJBs. We ll discuss many more application design examples later in the book; however, this first glimpse will let you decide on a particular approach as soon as possible. 2.2.1 Using Hibernate Annotations Let s first use Hibernate Annotations to replace the Hibernate XML mapping files with inline metadata. You may want to copy your existing Hello World project directory before you make the following changes you ll migrate from native Hibernate to standard JPA mappings (and program code later on). Copy the Hibernate Annotations libraries to your WORKDIR/lib directory see the Hibernate Annotations documentation for a list of required libraries. (At the time of writing, hibernate-annotations.jar and the API stubs in ejb3-persistence.jar were required.) Now delete the src/hello/Message.hbm.xml file. You ll replace this file with annotations in the src/hello/Message.java class source, as shown in listing 2.10.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.