Added method to return all shopping lists. Modified the save method to u...

...se the shopping list name as the primay key. Fixed the save method to work with multiple calls without resaving list items.
That statement isn't meant to actually update anything. Quantity is reset to current value. The updating should be handled in a different method I think. The intent of the ON DUPLICATE KEY is to ignore duplicate values. Unfortunately, the INSERT IGNORE command doesn't work with H2.


Sent via the Samsung Galaxy S™ III, an AT&T 4G LTE smartphone

-------- Original message --------
From: Niffer <notifications@github.com> 
Date: 07/14/2014  9:53 AM  (GMT-06:00) 
To: tinsweep/have-no-bananas <have-no-bananas@noreply.github.com> 
Cc: bthet4d <bryan.thetford@gmail.com> 
Subject: Re: [have-no-bananas] Added method to return all shopping lists. Modified the save method to u... (#9) 
 
In src/main/java/bananas/ShoppingListDAO.java:

> @@ -62,7 +84,7 @@ public void saveListOfItems(ListOfItems listToSave) throws DAOException{
>  			
>  			try {
>  				ps = con.prepareStatement("INSERT INTO " + listToSave.getName() + " "
> -						+ "(Name, Quantity, Price, Unit, Category) VALUES(?, ? , ? , ? , ?)");
> +						+ "(Name, Quantity, Price, Unit, Category) VALUES(?, ? , ? , ? , ?) ON DUPLICATE KEY UPDATE QUANTITY = QUANTITY");
Can it also update the price? And maybe the unit? Or can you only update one field at a time? ANother issue with updating all three at once is price & unit could be empty, so that might create problems.

—
Reply to this email directly or view it on GitHub.