JPA managed persistence now fully working

This commit is contained in:
Jeremy Grelle
2007-08-07 20:05:37 +00:00
parent 903d04cea8
commit 69a8021fa1
6 changed files with 12 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
@@ -57,7 +58,7 @@ public class Booking implements Serializable {
}
@Id
@GeneratedValue
@GeneratedValue(strategy = GenerationType.TABLE)
public Long getId() {
return id;
}

View File

@@ -40,6 +40,7 @@ public class JpaBookingService implements BookingService {
@Transactional(readOnly = true)
public Booking bookHotel(Hotel hotel, User user) {
Booking booking = new Booking(hotel, user);
em.persist(booking);
return booking;
}

View File

@@ -30,6 +30,9 @@
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="inMemoryDataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/>
</property>
</bean>
<bean id="inMemoryDataSource"

View File

@@ -6,4 +6,5 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
# Enable web flow logging
log4j.category.org.springframework.webflow=DEBUG
log4j.category.org.springframework.binding=DEBUG
log4j.category.org.springframework.binding=DEBUG
log4j.category.org.springframework.transaction=DEBUG

View File

@@ -18,7 +18,7 @@
<render-actions>
<bean-action bean="bookingService" method="readHotelById">
<method-arguments>
<argument expression="flowScope.id"/>
<argument expression="id"/>
</method-arguments>
<method-result name="hotel" scope="flow"/>
</bean-action>
@@ -30,8 +30,8 @@
<action-state id="bookHotel">
<bean-action bean="bookingService" method="bookHotel">
<method-arguments>
<argument expression="flowScope.hotel"/>
<argument expression="conversationScope.user"/>
<argument expression="hotel"/>
<argument expression="user"/>
</method-arguments>
<method-result name="booking" scope="flow"/>
</bean-action>

View File

@@ -27,7 +27,7 @@
<subflow-state flow="bookHotel-flow" id="bookHotel-flow">
<attribute-mapper>
<input-mapper>
<mapping source="requestParameters.id" target="id" from="string" to="long"/>
<mapping source="param.id" target="id" from="string" to="long"/>
</input-mapper>
</attribute-mapper>
<transition to="findBookings"/>