• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA PRO chapter 6 unsyncPC example modified

 
Himai Minh
Ranch Hand
Posts: 1361
7
  • 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: 1361
7
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic