nyheter
git-svn-id: svn://svn.dsv.su.se/scipro/scipro/trunk@531 73ecded7-942e-4092-bab0-0e58ef0ee984
This commit is contained in:
parent
6473f95626
commit
ec20e0df48
src/main/java/se/su/dsv/scipro/data/dao/jpa
@ -1,24 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EmbedResourceDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.EmbedResource;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("embedResourceDao")
|
||||
public class EmbedResourceDaoJPAImp extends AbstractDaoJPAImp<EmbedResource>
|
||||
implements EmbedResourceDao{
|
||||
|
||||
public EmbedResourceDaoJPAImp() {
|
||||
super(EmbedResource.class);
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileResourceDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileResource;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("fileResourceDao")
|
||||
public class FileResourceDaoJPAImp extends AbstractDaoJPAImp<FileResource>
|
||||
implements FileResourceDao {
|
||||
public FileResourceDaoJPAImp() {
|
||||
super(FileResource.class);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LinkResourceDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.LinkResource;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("linkResourceDao")
|
||||
public class LinkResourceDaoJPAImp extends AbstractDaoJPAImp<LinkResource>
|
||||
implements LinkResourceDao{
|
||||
|
||||
public LinkResourceDaoJPAImp() {
|
||||
super(LinkResource.class);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,6 @@
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
@ -15,11 +13,7 @@ import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RatableDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.LinkResource;
|
||||
import se.su.dsv.scipro.data.dataobjects.Ratable;
|
||||
import se.su.dsv.scipro.data.dataobjects.Rating;
|
||||
import se.su.dsv.scipro.data.dataobjects.Resource;
|
||||
import se.su.dsv.scipro.data.enums.RatingValue;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
@ -34,6 +28,7 @@ public class RatableDaoJPAImp extends AbstractDaoJPAImp<Ratable> implements
|
||||
super(Ratable.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int getRating(final Ratable ratable) {
|
||||
|
||||
|
@ -3,10 +3,21 @@
|
||||
*/
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.TagDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.PrivateMessage;
|
||||
import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
@ -14,11 +25,40 @@ import se.su.dsv.scipro.data.dataobjects.Tag;
|
||||
*/
|
||||
|
||||
@Repository("tagDao")
|
||||
public class TagDaoJPAImp extends AbstractDaoJPAImp<Tag>
|
||||
public class TagDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Tag>
|
||||
implements TagDao {
|
||||
|
||||
public TagDaoJPAImp() {
|
||||
super(Tag.class);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<Tag> findTagQuery(final String searchQuery,final int limit) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<Tag>>() {
|
||||
public List<Tag> doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Tag> query = em.createQuery("select t FROM Tag t WHERE t.tag LIKE '" + searchQuery + "%' ORDER BY t.tag ASC", Tag.class);
|
||||
query.setMaxResults(limit);
|
||||
try {
|
||||
return query.getResultList();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Tag findExactTagQuery(final String searchQuery) {
|
||||
return getJpaTemplate().execute(new JpaCallback<Tag>() {
|
||||
public Tag doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Tag> query = em.createQuery("select t FROM Tag t WHERE t.tag = '" + searchQuery +"'", Tag.class);
|
||||
try {
|
||||
return query.getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user