• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JPA PRO chapter 6 unsyncPC example modified

 
Bartender
Posts: 2421
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2421
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic