Java Reference
In-Depth Information
We have highlighted the attributes you need to add to persistence.xml . The at-
tribute name is a mandatory element that will be used to reference the persistence
unit from our Enterprise JavaBeans.
Then, we have specified some provider-specific properties, such as hibern-
ate.hbm2ddl.auto , that can be used to create and drop your database tables
each time you deploy your application. That can be an advantage if you want to start
with a clean storage each time you deploy the application. Additionally, we have in-
cluded another attribute, such as hibernate.show_sql , that (if turned on) can be
useful for debugging your Hibernate queries.
Adding producer classes
Producer classes have been introduced in the earlier chapter as a means of provid-
ing some object resources to our application. In this example, we will use it to pro-
duce lots of resources, such as the JPA Entity Manager and the list of objects that
are transferred to the JSF views. For this reason, we have provided a Resources
class that contains some general-purpose resources and single instances of the
SeatProducer and SeatTypeProducer classes, which will be used to produce
collections of entities.
Here's the first
com.packtpub.as7development.chapter5.producer.Resources class:
public class Resources {
@Produces
@PersistenceContext
private EntityManager em;
@Produces
public Logger produceLog(InjectionPoint
injectionPoint) {
return
Logger.getLogger(injectionPoint.getMember().getDeclaringClass().getName());
}
Search WWH ::




Custom Search