Skip to content

Instantly share code, notes, and snippets.

@jacobheric
Created April 25, 2013 15:42
Show Gist options
  • Save jacobheric/5460732 to your computer and use it in GitHub Desktop.
Save jacobheric/5460732 to your computer and use it in GitHub Desktop.
example java dao
//PersistenceExceptions will be auto-translated due to @Repository
@Repository("recipeService")
@RemotingDestination(channels = { "my-amf" })
@Transactional
public class RecipeDAO extends BaseDao<Recipe> implements RecipeService {
/**
* Constructor, see super class implementation.
*/
public RecipeDAO() {
super(new Recipe());
}
/**
* @param recipeName
* @return List<Recipe> - Recipes that match
* @throws Exception
*/
@RemotingInclude
@SuppressWarnings("unchecked")
public List<Recipe> findByName(String recipeName) throws Exception {
List<Recipe> recipes = (List<Recipe>)
this.getSessionFactory().getCurrentSession().createCriteria(Recipe.class)
.add( Restrictions.like("name", recipeName.trim(), MatchMode.ANYWHERE) ).list();
return recipes;
}
@RemotingInclude
@Override
public void delete(Recipe o) {
// TODO Auto-generated method stub
super.delete(o);
}
@RemotingInclude
@Override
public List<Recipe> findAll() {
// TODO Auto-generated method stub
return super.findAll();
}
@RemotingInclude
@Override
public Recipe findById(Long id) throws IllegalArgumentException,
SecurityException, InstantiationException, IllegalAccessException,
InvocationTargetException, NoSuchMethodException {
// TODO Auto-generated method stub
return super.findById(id);
}
@RemotingInclude
@Override
public Recipe insert(Recipe o) {
// TODO Auto-generated method stub
return super.insert(o);
}
@RemotingInclude
@Override
public Recipe update(Recipe o) {
// TODO Auto-generated method stub
return super.update(o);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment