Starting a Java Persistence project Listing 2.11 Persistence (Web site development)

Starting a Java Persistence project Listing 2.11 Persistence unit configuration file
Every persistence unit needs a name, and in this case it s helloworld. NOTE The XML header in the preceding persistence unit configuration file declares what schema should be used, and it s always the same. We ll omit it in future examples and assume that you ll add it. A persistence unit is further configured with an arbitrary number of properties, which are all vendor-specific. The property in the previous example, hibernate.ejb.cfgfile, acts as a catchall. It refers to a hibernate.cfg.xml file (in the root of the classpath) that contains all settings for this persistence unit you re reusing the existing Hibernate configuration. Later, you ll move all configuration details into the persistence.xml file, but for now you re more interested in running Hello World with JPA. The JPA standard says that the persistence.xml file needs to be present in the META-INF directory of a deployed persistence unit. Because you aren t really packaging and deploying the persistence unit, this means that you have to copy persistence. xml into a META-INF directory of the build output directory. Modify your build.xml, and add the following to the copymetafiles target:


Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.