org.broadleafcommerce.core.catalog.dao
Class CategoryDaoImpl

java.lang.Object
  extended by org.broadleafcommerce.core.catalog.dao.CategoryDaoImpl
All Implemented Interfaces:
CategoryDao

@Repository(value="blCategoryDao")
public class CategoryDaoImpl
extends java.lang.Object
implements CategoryDao

Author:
Jeff Fischer

Field Summary
protected  javax.persistence.EntityManager em
           
protected  EntityConfiguration entityConfiguration
           
protected  java.lang.String queryCacheableKey
           
 
Constructor Summary
CategoryDaoImpl()
           
 
Method Summary
 Category create()
          Create a new Category instance.
 void delete(Category category)
          Removed the passed in Category instance from the datastore
 java.lang.String getQueryCacheableKey()
           
 java.util.List<Category> readAllCategories()
          Retrieve all categories in the datastore
 java.util.List<Product> readAllProducts()
          Retrieve all products in the datastore
 java.util.List<Category> readAllSubCategories(Category category)
          Retrieve a list of all child categories of the passed in Category instance
 Category readCategoryById(java.lang.Long categoryId)
          Retrieve a Category instance by its primary key
 Category readCategoryByName(java.lang.String categoryName)
          Retrieve a Category instance by its name
 Category save(Category category)
          Persist a Category instance to the datastore
 void setQueryCacheableKey(java.lang.String queryCacheableKey)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

em

protected javax.persistence.EntityManager em

entityConfiguration

protected EntityConfiguration entityConfiguration

queryCacheableKey

protected java.lang.String queryCacheableKey
Constructor Detail

CategoryDaoImpl

public CategoryDaoImpl()
Method Detail

save

public Category save(Category category)
Description copied from interface: CategoryDao
Persist a Category instance to the datastore

Specified by:
save in interface CategoryDao
Parameters:
category - the Category instance
Returns:
the updated state of the passed in Category after being persisted

readCategoryById

public Category readCategoryById(java.lang.Long categoryId)
Description copied from interface: CategoryDao
Retrieve a Category instance by its primary key

Specified by:
readCategoryById in interface CategoryDao
Parameters:
categoryId - the primary key of the Category
Returns:
the Category at the specified primary key

readCategoryByName

public Category readCategoryByName(java.lang.String categoryName)
Description copied from interface: CategoryDao
Retrieve a Category instance by its name

Specified by:
readCategoryByName in interface CategoryDao
Parameters:
categoryName - the name of the category
Returns:
the Category having the specified name

readAllCategories

public java.util.List<Category> readAllCategories()
Description copied from interface: CategoryDao
Retrieve all categories in the datastore

Specified by:
readAllCategories in interface CategoryDao
Returns:
a list of all the Category instances in the datastore

readAllProducts

public java.util.List<Product> readAllProducts()
Description copied from interface: CategoryDao
Retrieve all products in the datastore

Specified by:
readAllProducts in interface CategoryDao
Returns:
a list of all Category instances in the datastore, regardless of their category association

readAllSubCategories

public java.util.List<Category> readAllSubCategories(Category category)
Description copied from interface: CategoryDao
Retrieve a list of all child categories of the passed in Category instance

Specified by:
readAllSubCategories in interface CategoryDao
Parameters:
category - the parent category
Returns:
a list of all child categories

getQueryCacheableKey

public java.lang.String getQueryCacheableKey()

setQueryCacheableKey

public void setQueryCacheableKey(java.lang.String queryCacheableKey)

delete

public void delete(Category category)
Description copied from interface: CategoryDao
Removed the passed in Category instance from the datastore

Specified by:
delete in interface CategoryDao
Parameters:
category - the Category instance to remove

create

public Category create()
Description copied from interface: CategoryDao
Create a new Category instance. The system will use the configuration in /BroadleafCommerce/core/BroadleafCommerceFramework/src/main/resources/bl-framework-applicationContext-entity.xml to determine which polymorphic version of Category to instantiate. To make Broadleaf instantiate your extension of Category by default, include an entity configuration bean in your application context xml similar to:

<bean id="blEntityConfiguration" class="org.broadleafcommerce.persistence.EntityConfiguration"> <property name="entityContexts"> <list> <value>classpath:myCompany-applicationContext-entity.xml</value> </list> </property> </bean>

Declare the same key for your desired entity in your entity xml that is used in the Broadleaf entity xml, but change the value to the fully qualified classname of your entity extension.

Specified by:
create in interface CategoryDao
Returns:
a Category instance based on the Broadleaf entity configuration.


Copyright © 2011. All Rights Reserved.