• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

JPA PRO chapter 6 unsyncPC example modified  RSS feed

 
Ranch Hand
Posts: 1732
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I added some notes to the unsynPC example:
1. include cdi-api.jar in the classpath. You can find it from your glassfish installation path/glassfish/modules.
Without it, it won't compile the ShoppingCart stateful bean with @SessionScope annotation.

2. In the sql statements provided, it is better to add auto increment for the keys of the two tables like this;


3. Add a web.xml like this:
 
Himai Minh
Ranch Hand
Posts: 1732
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found out that the original code of unsync in chapter 6 does not work when I restarted and redeploy the application.

For your reference , I made more modification to the example  to make it work:
1. I added a foreign key to the orderitem table:






The book uses 1, 2, 3.... for the id of customerID. That will cause duplicated primary key problem if you run this example for more than once.
That is why I decided to use automated generated ID.

In the shopping cart stateful bean, I modified into this:



Now, you will get something like this:
CUSTOMERORDER Table:
ID  | Name
---------------------
1       pants_order

ORDERITEM table:
ID| Name |Quantity| item key | order id
----------------------------------------------
1      pants     100        pants           1
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!