Permalink
Browse files

Added db files for basic/write-through and cleaned up repository example

  • Loading branch information...
1 parent d69afff commit a23915040855608c46e9cfe08bc89d5e5e1ab4b3 @dturanski dturanski committed Sep 25, 2012
View
@@ -29,7 +29,6 @@ target/
# Logs and databases #
######################
*.log
-*.sql
*.sqlite
*.state
*.lock
@@ -60,7 +60,7 @@ public Customer createCustomer(Customer customer) {
*/
public boolean deleteCustomer(long id) {
- Customer customer = customerRepository.findById(id);
+ Customer customer = customerRepository.findOne(id);
if (customer != null) {
customerRepository.delete(customer);
log.debug("deleted customer " + customer.getId()+ ":" + customer.getFirstname()+ " " + customer.getLastname());
@@ -86,7 +86,7 @@ public boolean deleteCustomer(Customer customer) {
* @return
*/
public Customer getCustomer(long id) {
- return customerRepository.findById(id);
+ return customerRepository.findOne(id);
}
/**
@@ -97,8 +97,8 @@ private void findOrders() {
for (LineItem lineItem: order.getLineItems()) {
log.debug("product ID:" + lineItem.getProductId() +
" quantity:" + lineItem.getAmount() +
- " unit price:" + lineItem.getUnitPrice() +
- " total price:" + lineItem.getTotal());
+ " unit price:" + lineItem.getUnitPrice().setScale(2,BigDecimal.ROUND_DOWN) +
+ " total price:" + lineItem.getTotal().setScale(2,BigDecimal.ROUND_DOWN));
}
}
}
@@ -20,7 +20,7 @@
import org.springframework.data.gemfire.examples.domain.Customer;
import org.springframework.data.gemfire.examples.domain.EmailAddress;
-import org.springframework.data.repository.Repository;
+import org.springframework.data.gemfire.repository.GemfireRepository;
/**
* Repository interface to access {@link Customer}s.
@@ -29,34 +29,14 @@
* @author David Turanski
*/
-public interface CustomerRepository extends Repository<Customer, Long> {
-
+public interface CustomerRepository extends GemfireRepository<Customer, Long> {
+
/**
* Returns all {@link Customer}s.
*
* @return
*/
Set<Customer> findAll();
-
- /**
- * Find unique customer with a given Id
- */
- Customer findById(long id);
-
- /**
- * Saves the given {@link Customer}.
- *
- * @param customer the {@link Customer} to save.
- * @return
- */
- Customer save(Customer customer);
-
- /**
- * Deletes the given {@link Customer}.
- *
- * @param customer
- */
- void delete(Customer customer);
/**
* Finds all {@link Customer}s with the given lastname.
@@ -26,7 +26,7 @@
* Repository interface to access {@link Product}s.
*
* @author Oliver Gierke
- * @author David TuranskiGem
+ * @author David Turanski
*/
public interface ProductRepository extends CrudRepository<Product, Long> {
@@ -19,7 +19,6 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
-import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**

0 comments on commit a239150

Please sign in to comment.