org.openwms.core.integration.jpa
Class PreferencesDaoImpl

java.lang.Object
  extended by org.openwms.core.integration.jpa.PreferencesDaoImpl
All Implemented Interfaces:
PreferenceDao<Long>, PreferenceWriter<Long>

@Transactional(propagation=MANDATORY)
@Repository(value="preferencesJpaDao")
public class PreferencesDaoImpl
extends Object
implements PreferenceWriter<Long>

A PreferencesDaoImpl is a JPA implementation of PreferenceWriter and implicitly of PreferenceDao to find, remove and save preference objects to the persistent storage. It can be injected by name "preferencesJpaDao".

All methods have to be invoked within an active transaction context.

Since:
0.1
Version:
$Revision: $
Author:
Heiko Scherrer

Field Summary
static String COMPONENT_NAME
          Springs component name.
 
Constructor Summary
PreferencesDaoImpl()
           
 
Method Summary
 List<AbstractPreference> findAll()
          Find all entities and return them as a List.
 AbstractPreference findByKey(Long id)
          Find and return the entity identified by the natural unique key.
<T extends AbstractPreference>
List<T>
findByType(Class<T> clazz)
          Find all preferences of a particular type.
<T extends AbstractPreference>
void
persist(T entity)
          Force a persist of a new entity.
 void remove(AbstractPreference entity)
          Removes an already persistent entity.
<T extends AbstractPreference>
T
save(T entity)
          Save an entity with the persistence layer and return it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_NAME

public static final String COMPONENT_NAME
Springs component name.

See Also:
Constant Field Values
Constructor Detail

PreferencesDaoImpl

public PreferencesDaoImpl()
Method Detail

findByKey

public AbstractPreference findByKey(Long id)
Find and return the entity identified by the natural unique key.

Specified by:
findByKey in interface PreferenceDao<Long>
Parameters:
id - Natural key to find the entity (also known as business key)
Returns:
The found entity
See Also:
PreferenceDao.findByKey(java.io.Serializable)

findByType

public <T extends AbstractPreference> List<T> findByType(Class<T> clazz)
Find all preferences of a particular type.

Specified by:
findByType in interface PreferenceDao<Long>
Type Parameters:
T - Any subtype of AbstractPreference
Parameters:
clazz - The type to search for
Returns:
A list of entities
See Also:
PreferenceDao.findByType(java.lang.Class)

findAll

public List<AbstractPreference> findAll()
Find all entities and return them as a List.

Specified by:
findAll in interface PreferenceDao<Long>
Returns:
List of all entities
See Also:
PreferenceDao.findAll()

save

public <T extends AbstractPreference> T save(T entity)
Save an entity with the persistence layer and return it. Call EntityManager.persist(Object) for transient instances and EntityManager.merge(Object) for detached and managed ones.

Specified by:
save in interface PreferenceWriter<Long>
Type Parameters:
T - Any subtype of AbstractPreference
Parameters:
entity - Entity instance to be synchronized with the persistence layer
Returns:
The synchronized entity instance. If JPA is used as implementation, the returned instance is managed
See Also:
PreferenceWriter.save(org.openwms.core.domain.system.AbstractPreference)

persist

public <T extends AbstractPreference> void persist(T entity)
Force a persist of a new entity.

Specified by:
persist in interface PreferenceWriter<Long>
Type Parameters:
T - Some kind ofAbstractPreference
Parameters:
entity - The entity to persist
See Also:
PreferenceWriter.persist(org.openwms.core.domain.system.AbstractPreference)

remove

public void remove(AbstractPreference entity)
Removes an already persistent entity. If entity is not already managed, call EntityManager.merge(Object) before to attach it to the persistence context.

Specified by:
remove in interface PreferenceWriter<Long>
Parameters:
entity - Entity instance to be removed
See Also:
PreferenceWriter.remove(org.openwms.core.domain.system.AbstractPreference)


Copyright © 2005-2011 openwms.org. All Rights Reserved.