• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPA /springs ApplicationContext.xml

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to JPA can any one explain why and what purpose we using following all springs class [1) to 8)] and also purpose of persistence.xml

1)org.apache.struts2.dispatcher.FilterDispatcher
2)org.springframework.web.context.ContextLoaderListener

<bean
3)class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

<bean id="personService" class="quickstart.service.PersonServiceImpl" />

<bean id="entityManagerFactory"
4)class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
5) class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="MYSQL" />
<property name="showSql" value="true" />
</bean>
</property>
</bean>

<bean id="dataSource"
6)class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/quickstart" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>
7)
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
8)
<tx:annotation-driven transaction-manager="transactionManager" />
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not going to give you a detailed explanation of each class, but the general concept is this:

JPA is an standard only, just as Java EE is a standard only. In order to make both work, you must have an implementation of that standard or API.

For example, the authors of the Java EE standard didn't actually write an application server. They provided a standard for writing application servers. IBM, BEA, RedHat and others then created WebSphere, WebLogic, JBoss, etc. all of which implement the Java EE standard.

In the same manner, various vendors or open source projects have created implementations of the JPA standard. The example you've chosen happens to be the Spring/Hibernate implementation of the JPA standard. If you had chosen the Toplink implementation or the OpenJPA implementation, you would see no Spring-specific classes in those implementations.

This question has only marginal relevance to this forum because it appears to be in a Struts 2 application. If you need more understanding of how Spring, JPA, or Hibernate work, your best bet would be to ask these questions in forums more appropriate to those topics.

Oh, and one other thing: Please review the JavaRanch Naming Policy and adjust your displayed name accordingly.
[ March 10, 2008: Message edited by: Merrill Higginson ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic