// Copyright 2010 Thiago H. de Paula Figueiredo
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package br.com.machina.verbum.dao;
import java.util.List;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import br.com.machina.verbum.entities.Blog;
import br.com.machina.verbum.entities.Post;
/**
* Hibernate DAO implementation for {@link Post}.
*
* @author Thiago H. de Paula Figueiredo
*/
public interface PostDAO {
/**
* Inserts or updates an post.
* @param post an {@link Post}.
*/
@CommitAfter
void saveOrUpdate(Post post);
/**
* Returns the n latest posts from all blogs.
*
* @param maximum the maximum number of posts to return.
* @return a {@link List} of {@link Post}s.
*/
List<Post> findLatest(int maximum);
/**
* Returns all posts.
* @return a {@link List} of {@link Post}s.
*/
List<Post> findAll();
/**
* Removes an post.
* @param post an {@link Post}.
*/
@CommitAfter
void remove(Post post);
/**
* Find a post by its id.
*
* @return a {@link Post} or <code>null</code>.
*/
Post findById(int id);
/**
* Find posts by blog.
*
* @return @return a {@link List} of {@link Post}s.
*/
List<Post> findByBlog(Blog blog);
}