Commentthread
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@261 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
1e433fc75b
commit
cf63256e37
@ -0,0 +1,50 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CommentThreadDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.CommentThread;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.enums.ProjectStatus;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class CommentThreadDaoJPAImp extends AbstractDaoJPAImp<CommentThread>
|
||||
implements CommentThreadDao {
|
||||
|
||||
public CommentThreadDaoJPAImp() {
|
||||
super(CommentThread.class);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public CommentThread getCommentThreadByClassAndId(final String className, final long classId) {
|
||||
return getJpaTemplate().execute(new JpaCallback<CommentThread>() {
|
||||
public CommentThread doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
String q = "select t " +
|
||||
"from CommentThread t " +
|
||||
"where t.className = className and t.classId = t.classId ";
|
||||
|
||||
|
||||
TypedQuery<CommentThread> query = em.createQuery(q, CommentThread.class);
|
||||
query.setParameter("className", className);
|
||||
query.setParameter("classId", classId);
|
||||
|
||||
return query.getSingleResult();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user