[JBoss Seam] - Seam 2.0 NOT support OpenJPA?
by davidclf
I try to test the Seam's compatibility with openjpa.
The web project is tomacat + myfaces + seam + spring jpa + openjpa.
I define entityManagerFactory in the application.xml
| <!-- JPA EntityManagerFactory -->
| <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
| <property name="dataSource" ref="dataSource"/>
| <property name="loadTimeWeaver">
| <bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
| </property>
| <property name="jpaVendorAdapter">
| <!--
| <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
| <property name="databasePlatform"
| value="org.springframework.samples.petclinic.toplink.EssentialsHSQLPlatformWithNativeSequence"/>
| <property name="showSql" value="true"/>
| </bean>
| -->
| <!--
| <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
| <property name="database" value="HSQL"/>
| <property name="showSql" value="true"/>
| </bean>
| -->
| <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
| <property name="database" value="HSQL"/>
| <property name="showSql" value="true"/>
| </bean>
| </property>
| </bean>
|
And Define managed-persistence-context in component.xml
| <persistence:managed-persistence-context name="courseEntityManager"
| entity-manager-factory="#{entityManagerFactory}"
| auto-create="true" />
|
The Web Project reports Error
| 2007-09-21 09:21:09,981 ERROR [org.jboss.seam.jsf.SeamPhaseListener] - <uncaught exception>
| java.lang.RuntimeException: could not proxy delegate
| at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:102)
| Caused by: java.lang.ClassCastException: org.apache.openjpa.persistence.EntityManagerImpl
| at org.jboss.seam.persistence.HibernatePersistenceProvider.proxyDelegate(HibernatePersistenceProvider.java:98)
|
Is it Means that Seam 2.0 Not Support OpenJPA? or Am I Wrong?
AnyOne Can Help? Thank in Advance!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086999#4086999
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086999
18 years, 9 months
[JBoss Seam] - Booking Example - Do I miss the point about transactions?
by vanyatka
Hi,
If we have a look at the BookingListAction class (listed below), its transaction attribute suggests, that each method in that class will trigger a new transaction. My question is about the cancel() method, which as you can see removes the booking, and updates the list of bookings. What confuses me is that getBookings() is called from cancel(), before cancel() is finished, which means that cancel's transaction is not commited and no changes is made persistent. According to my understanding getBookings() should get the same unupdated list of objects, which makes no sense and in fact is not true. Can anyone kindly suggest what I miss here? Thanks
@Stateful
| @Scope(SESSION)
| @Name("bookingList")
| @Restrict("#{identity.loggedIn}")
| @TransactionAttribute(REQUIRES_NEW)
| public class BookingListAction implements BookingList, Serializable
| {
| private static final long serialVersionUID = 1L;
| @PersistenceContext
| private EntityManager em;
|
| @In
| private User user;
|
| @DataModel
| private List<Booking> bookings;
| @DataModelSelection
| private Booking booking;
|
| @Logger
| private Log log;
|
| @Factory
| @Observer("bookingConfirmed")
| public void getBookings()
| {
| bookings = em.createQuery("select b from Booking b where b.user.username = :username order by b.checkinDate")
| .setParameter("username", user.getUsername())
| .getResultList();
| }
|
| public void cancel()
| {
| log.info("Cancel booking: #{bookingList.booking.id} for #{user.username}");
| Booking cancelled = em.find(Booking.class, booking.getId());
| if (cancelled!=null) em.remove( cancelled );
| getBookings();
| FacesMessages.instance().add("Booking cancelled for confirmation number #{bookingList.booking.id}");
| }
|
| public Booking getBooking()
| {
| return booking;
| }
|
| @Destroy @Remove
| public void destroy() {}
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4086995#4086995
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4086995
18 years, 9 months