src/com/dream/dao/DaoSupport.java

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.dream.dao;

import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.LinkedHashMap;

import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dream.page.QueryResult;

@Transactional
public abstract class DaoSupport implements DAO{

	@PersistenceContext protected EntityManager em ;
	public <T> void delete(Class<T> entityclass,Object entityid) {
		this.delete(entityclass, new Object[]{entityid});
	}

	public <T> void delete(Class<T> entityclass,Object[] entityids) {
		for(Object entityid:entityids){
			em.remove(em.getReference(entityclass, entityid));
		}
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public <T> T find(Class<T> entityclass, Object entityid) {
		return em.find(entityclass, entityid);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public <T> T getReference(Class<T> entityclass, Object entityid) {
		return em.getReference(entityclass, entityid);
	}
	
	public void save(Object entity) {
		em.persist(entity);
	}
	public void saves(Object[] entitys) {
		for(Object entity:entitys){
			em.persist(entity);
		}
	}
	public void update(Object entity) {
		em.merge(entity);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public <T> QueryResult getScrollData(Class<T> entityClass, int firstindex,
			int maxresult,String wherejpql,Object[]queryParams,LinkedHashMap<String,String> orderby) {
		QueryResult qr = new QueryResult<T>();
		String entityname = getEntityName(entityClass);
		Query query = em.createQuery("select o from "+ entityname+ " o "+(wherejpql==null? "": "where "+ wherejpql)+ buildOrderby(orderby));
后面还有 91 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。