CHAPTER 2 Starting a project Also note that we added some line breaks in the property values to make this more readable you shouldn t do this in your real configuration file (unless your database username contains a line break). Configuring the persistence unit Next, you need to change the persistence unit configuration of the Hello World application to access a managed JTA datasource, instead of a resource-local connection pool. Change your WORKDIR/etc/META-INF/persistence.xml file as follows:
java:/HelloWorldDS
You removed many Hibernate configuration options that are no longer relevant, such as the connection pool and database connection settings. Instead, you set a property with the name of the datasource as bound in JNDI. Don t forget that you still need to configure the correct SQL dialect and any other Hibernate options that aren t present in default.persistence.properties. The installation and configuration of the environment is now complete, (we ll show you the purpose of the jndi.properties files in a moment) and you can rewrite the application code with EJBs. Writing EJBs There are many ways to design and create an application with managed components. The Hello World application isn t sophisticated enough to show elaborate examples, so we ll introduce only the most basic type of EJB, a stateless session bean. (You ve already seen entity classes annotated plain Java classes that can have persistent instances. Note that the term entity bean only refers to the old EJB 2.1 entity beans; EJB 3.0 and Java Persistence standardize a lightweight programming model for plain entity classes.)
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.
This entry was posted
on Sunday, October 28th, 2007 at 2:17 am and is filed under PHP5.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.