diff --git a/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
index 00d2bc31..dc60e9f3 100755
--- a/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
+++ b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
@@ -40,6 +40,12 @@ public interface BookingService {
*/
public Booking createBooking(Long hotelId, String userName);
+ /**
+ * Persist the booking to the database
+ * @param booking the booking
+ */
+ public void persistBooking(Booking booking);
+
/**
* Cancel an existing booking.
* @param id the booking id
diff --git a/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
index e68a4206..3f23df10 100755
--- a/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
+++ b/spring-webflow-samples/booking-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
@@ -46,20 +46,22 @@ public class JpaBookingService implements BookingService, Serializable {
String pattern = getSearchPattern(criteria);
orderBy = (orderBy != null) ? orderBy : "name";
String orderDirection = (ascending) ? " ASC" : " DESC";
- return em.createQuery(
- "select h from Hotel h where lower(h.name) like :pattern or lower(h.city) like :pattern "
- + "or lower(h.zip) like :pattern or lower(h.address) like :pattern order by h." + orderBy
- + orderDirection).setParameter("pattern", pattern).setMaxResults(criteria.getPageSize())
- .setFirstResult(firstResult).getResultList();
+ return em
+ .createQuery(
+ "select h from Hotel h where lower(h.name) like :pattern or lower(h.city) like :pattern "
+ + "or lower(h.zip) like :pattern or lower(h.address) like :pattern order by h."
+ + orderBy + orderDirection).setParameter("pattern", pattern)
+ .setMaxResults(criteria.getPageSize()).setFirstResult(firstResult).getResultList();
}
@Transactional(readOnly = true)
public int getNumberOfHotels(SearchCriteria criteria) {
String pattern = getSearchPattern(criteria);
- Long count = (Long) em.createQuery(
- "select count(h.id) from Hotel h where lower(h.name) like :pattern or lower(h.city) like :pattern "
- + "or lower(h.zip) like :pattern or lower(h.address) like :pattern").setParameter("pattern",
- pattern).getSingleResult();
+ Long count = (Long) em
+ .createQuery(
+ "select count(h.id) from Hotel h where lower(h.name) like :pattern or lower(h.city) like :pattern "
+ + "or lower(h.zip) like :pattern or lower(h.address) like :pattern")
+ .setParameter("pattern", pattern).getSingleResult();
return count.intValue();
}
@@ -73,11 +75,14 @@ public class JpaBookingService implements BookingService, Serializable {
Hotel hotel = em.find(Hotel.class, hotelId);
User user = findUser(username);
Booking booking = new Booking(hotel, user);
- em.persist(booking);
return booking;
}
- // read-write transactional methods
+ @Transactional
+ public void persistBooking(Booking booking) {
+ em.persist(booking);
+ }
+
@Transactional
public void cancelBooking(Booking booking) {
booking = em.find(Booking.class, booking.getId());
@@ -97,8 +102,8 @@ public class JpaBookingService implements BookingService, Serializable {
}
private User findUser(String username) {
- return (User) em.createQuery("select u from User u where u.username = :username").setParameter("username",
- username).getSingleResult();
+ return (User) em.createQuery("select u from User u where u.username = :username")
+ .setParameter("username", username).getSingleResult();
}
}
\ No newline at end of file
diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/config/webflow-config.xml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/config/webflow-config.xml
index 6948bc17..cf2c27d2 100644
--- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/config/webflow-config.xml
+++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/config/webflow-config.xml
@@ -12,7 +12,6 @@
-
@@ -27,12 +26,6 @@
-
-
-
-
-
-
diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/booking-flow.xml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/booking-flow.xml
index 31eaa029..16508198 100755
--- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/booking-flow.xml
+++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/booking-flow.xml
@@ -5,8 +5,6 @@
-
-
@@ -19,12 +17,14 @@
-
+
+
+
-
+
diff --git a/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
index c12d26da..f6b6f9d2 100755
--- a/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
+++ b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
@@ -37,6 +37,12 @@ public interface BookingService {
*/
public Booking createBooking(Long hotelId, String userName);
+ /**
+ * Persist the booking to the database
+ * @param booking the booking
+ */
+ public void persistBooking(Booking booking);
+
/**
* Cancel an existing booking.
* @param id the booking id
diff --git a/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
index 9893c704..e88436ef 100755
--- a/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
+++ b/spring-webflow-samples/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
@@ -60,10 +60,14 @@ public class JpaBookingService implements BookingService {
Hotel hotel = em.find(Hotel.class, hotelId);
User user = findUser(username);
Booking booking = new Booking(hotel, user);
- em.persist(booking);
return booking;
}
+ @Transactional
+ public void persistBooking(Booking booking) {
+ em.persist(booking);
+ }
+
@Transactional
public void cancelBooking(Long id) {
Booking booking = em.find(Booking.class, id);
diff --git a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/config/webflow-config.xml b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/config/webflow-config.xml
index c2b32d89..a8b343c8 100644
--- a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/config/webflow-config.xml
+++ b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/config/webflow-config.xml
@@ -11,7 +11,6 @@
-
@@ -20,7 +19,7 @@
-
+
@@ -31,16 +30,10 @@
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml
index e3b3abaf..d746efef 100644
--- a/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml
+++ b/spring-webflow-samples/booking-mvc/src/main/webapp/WEB-INF/hotels/booking/booking-flow.xml
@@ -5,8 +5,6 @@
-
-
@@ -30,12 +28,14 @@
-
+
+
+
-
+
diff --git a/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java b/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
index 14e841e4..59a333f3 100644
--- a/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
+++ b/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
@@ -8,46 +8,52 @@ import java.util.List;
*/
public interface BookingService {
- /**
- * Find bookings made by the given user
- * @param username the user's name
- * @return their bookings
- */
- public List findBookings(String username);
+ /**
+ * Find bookings made by the given user
+ * @param username the user's name
+ * @return their bookings
+ */
+ public List findBookings(String username);
- /**
- * Find hotels available for booking by some criteria.
- * @param criteria the search criteria
- * @return a list of hotels meeting the criteria
- */
- public List findHotels(SearchCriteria criteria);
+ /**
+ * Find hotels available for booking by some criteria.
+ * @param criteria the search criteria
+ * @return a list of hotels meeting the criteria
+ */
+ public List findHotels(SearchCriteria criteria);
- /**
- * Find hotels by their identifier.
- * @param id the hotel id
- * @return the hotel
- */
- public Hotel findHotelById(Long id);
+ /**
+ * Find hotels by their identifier.
+ * @param id the hotel id
+ * @return the hotel
+ */
+ public Hotel findHotelById(Long id);
- /**
- * Find user by their username.
- * @param username the user's username
- * @return the user
- */
- public User findUser(String username);
+ /**
+ * Find user by their username.
+ * @param username the user's username
+ * @return the user
+ */
+ public User findUser(String username);
- /**
- * Create a new, transient hotel booking instance for the given user.
- * @param hotelId the hotelId
- * @param userName the user name
- * @return the new transient booking instance
- */
- public Booking createBooking(Long hotelId, String userName);
+ /**
+ * Create a new, transient hotel booking instance for the given user.
+ * @param hotelId the hotelId
+ * @param userName the user name
+ * @return the new transient booking instance
+ */
+ public Booking createBooking(Long hotelId, String userName);
- /**
- * Cancel an existing booking.
- * @param id the booking id
- */
- public void cancelBooking(Booking booking);
+ /**
+ * Persist the booking to the database
+ * @param booking the booking
+ */
+ public void persistBooking(Booking booking);
+
+ /**
+ * Cancel an existing booking.
+ * @param id the booking id
+ */
+ public void cancelBooking(Booking booking);
}
diff --git a/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java b/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
index f15f7061..b5304110 100644
--- a/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
+++ b/spring-webflow-samples/booking-portlet-faces/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
@@ -67,7 +67,11 @@ public class JpaBookingService implements BookingService {
return new Booking(hotel, user);
}
- // read-write transactional methods
+ @Transactional
+ public void persistBooking(Booking booking) {
+ em.persist(booking);
+ }
+
@Transactional
public void cancelBooking(Booking booking) {
booking = em.find(Booking.class, booking.getId());
diff --git a/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml b/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml
index 970be7e3..6526dc0f 100644
--- a/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml
+++ b/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml
@@ -37,7 +37,6 @@
-
@@ -53,11 +52,5 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/flows/booking/booking.xml b/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/flows/booking/booking.xml
index 180c0ecc..a3abd47d 100644
--- a/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/flows/booking/booking.xml
+++ b/spring-webflow-samples/booking-portlet-faces/src/main/webapp/WEB-INF/flows/booking/booking.xml
@@ -3,8 +3,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
-
-
@@ -20,13 +18,13 @@
-
+
-
+
diff --git a/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java b/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
index df1501f7..5a1978ff 100644
--- a/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
+++ b/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingService.java
@@ -44,6 +44,12 @@ public interface BookingService {
*/
public Booking createBooking(Long hotelId, String userName);
+ /**
+ * Persist the booking to the database
+ * @param booking the booking
+ */
+ public void persistBooking(Booking booking);
+
/**
* Cancel an existing booking.
* @param id the booking id
diff --git a/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java b/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
index 0d827023..6a365256 100644
--- a/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
+++ b/spring-webflow-samples/booking-portlet-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java
@@ -67,6 +67,11 @@ public class JpaBookingService implements BookingService {
return new Booking(hotel, user);
}
+ @Transactional
+ public void persistBooking(Booking booking) {
+ em.persist(booking);
+ }
+
@Transactional
public void cancelBooking(Long id) {
Booking booking = em.find(Booking.class, id);
diff --git a/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml b/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml
index 94078d12..f3cc03aa 100644
--- a/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml
+++ b/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/config/hotelbooking-portlet-config.xml
@@ -31,11 +31,7 @@
-
-
-
-
-
+
@@ -47,13 +43,7 @@
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/flows/booking/booking.xml b/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/flows/booking/booking.xml
index d58872b6..f7cd26f3 100644
--- a/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/flows/booking/booking.xml
+++ b/spring-webflow-samples/booking-portlet-mvc/src/main/webapp/WEB-INF/flows/booking/booking.xml
@@ -5,8 +5,6 @@
-
-
@@ -20,7 +18,7 @@
-
+