JPA managed persistence now fully working
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
@@ -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>
|
||||
|
||||
@@ -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"/>
|
||||
|
||||
Reference in New Issue
Block a user