package com.stbr.common.mongodb.base;
import com.mongodb.WriteResult;
import com.stbr.common.mongodb.util.MongoFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import java.util.Map;
public class BaseMongoDao implements IBaseMongoDao{
private Class clazz;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private MongoFactory mongoFactory;
public BaseMongoDao() {
ParameterizedType parameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
clazz = (Class) parameterizedType.getActualTypeArguments()[0];
}
@Override
public void insert(T entity) {
mongoTemplate.insert(entity);
}
@Override
public T findOne(String id) {
Query query = new Query();
query.addCriteria(new Criteria("_id").is(id));
return getMongoTemplate().findOne(query,clazz);
}
@Override
public List find(Query query) {
return getMongoTemplate().find(query,clazz);
}
@Override
public Long findCount(Query query) {
return getMongoTemplate().count(query,clazz);
}
@Override
public List findList(Integer skip, Integer limit,Query query) {
query.with(new Sort(new Sort.Order(Sort.Direction.ASC,"createTime")));
query.skip(skip).limit(limit);
return find(query);
}
@Override
public Integer update(Query query, Update update) throws Exception {
WriteResult writeResult = getMongoTemplate().updateFirst(query,update,clazz);
return (null == writeResult ? 0 : writeResult.getN());
}
@Override
public Integer update(T entity) throws Exception {
Map map = mongoFactory.converObjectToParams(entity);
Query query = new Query();
query.addCriteria(new Criteria("_id").is(map.get("id")));
Update update = (Update) map.get("update");
return this.update(query,update);
}
@Override
public Integer remove(T entity) {
WriteResult writeResult = getMongoTemplate().remove(entity);
return (null == writeResult ? 0 : writeResult.getN());
}
@Override
public Integer remove(Query query, T entity) {
WriteResult writeResult = getMongoTemplate().remove(query,entity.getClass());
return (null == writeResult ? 0 : writeResult.getN());
}
public MongoTemplate getMongoTemplate(){
return mongoTemplate;
}
}
IBaseMongoDao
package com.stbr.common.mongodb.base;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import java.util.List;
public interface IBaseMongoDao {
public T findOne(String id);
public List find(Query query);
public Long findCount(Query query);
public List findList(Integer skip,Integer limit,Query query);
public void insert(T entity);
public Integer update(Query query, Update update) throws Exception;
public Integer update(T entity) throws Exception;
public Integer remove(T entity);
public Integer remove(Query query,T entity);
}
IMongoEntityDao
package com.stbr.common.mongodb.dao;
import com.stbr.common.mongodb.base.IBaseMongoDao;
import com.stbr.common.mongodb.model.MongoEntity;
public interface IMongoEntityDao extends IBaseMongoDao{
public MongoEntity getMongoEntityById(String id);
}
MongoEntityDao
package com.stbr.common.mongodb.dao;
import com.stbr.common.mongodb.base.BaseMongoDao;
import com.stbr.common.mongodb.model.MongoEntity;
import org.springframework.stereotype.Repository;
@Repository
public class MongoEntityDao extends BaseMongoDao implements IMongoEntityDao{
@Override
public MongoEntity getMongoEntityById(String id) {
MongoEntity mongoEntity = findOne(id);
return mongoEntity;
}
}
MongoEntity
package com.stbr.common.mongodb.model;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "mongoLogInfo")
public class MongoEntity {
@Id
private String id;//主键
private String interfaceMethod;//接口方法名称
private String businessName;//业务名称
private String clientReqParams;//客户端请求参数
private String serviceRepParams;//服务端响应参数
private String logInfo;//日志内容:包括异常等
private Long clientReqTime;//客户端调用时间
private Long serviceRepTime;//服务端响应时间
private Long duration;//持续时间
private String clientReqIpPort;//客户端请求IP和PORT
private String serviceRepIpPort;//服务端响应IP和PORT
private String ifSuccess;//服务调用是否成功标识,1成功2失败
private Long createTime;//插入时间
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getInterfaceMethod() {
return interfaceMethod;
}
public void setInterfaceMethod(String interfaceMethod) {
this.interfaceMethod = interfaceMethod;
}
public String getBusinessName() {
return businessName;
}
public void setBusinessName(String businessName) {
this.businessName = businessName;
}
public String getClientReqParams() {
return clientReqParams;
}
public void setClientReqParams(String clientReqParams) {
this.clientReqParams = clientReqParams;
}
public String getServiceRepParams() {
return serviceRepParams;
}
public void setServiceRepParams(String serviceRepParams) {
this.serviceRepParams = serviceRepParams;
}
public String getLogInfo() {
return logInfo;
}
public void setLogInfo(String logInfo) {
this.logInfo = logInfo;
}
public Long getClientReqTime() {
return clientReqTime;
}
public void setClientReqTime(Long clientReqTime) {
this.clientReqTime = clientReqTime;
}
public Long getServiceRepTime() {
return serviceRepTime;
}
public void setServiceRepTime(Long serviceRepTime) {
this.serviceRepTime = serviceRepTime;
}
public Long getDuration() {
return duration;
}
public void setDuration(Long duration) {
this.duration = duration;
}
public String getClientReqIpPort() {
return clientReqIpPort;
}
public void setClientReqIpPort(String clientReqIpPort) {
this.clientReqIpPort = clientReqIpPort;
}
public String getServiceRepIpPort() {
return serviceRepIpPort;
}
public void setServiceRepIpPort(String serviceRepIpPort) {
this.serviceRepIpPort = serviceRepIpPort;
}
public String getIfSuccess() {
return ifSuccess;
}
public void setIfSuccess(String ifSuccess) {
this.ifSuccess = ifSuccess;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
}
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
Caused by: javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:102)
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.(ResourceBundleMessageInterpolator.java:45)
at org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultMessageInterpolator(ConfigurationImpl.java:423)
Caused by: javax.el.ELException: Provider com.sun.el.ExpressionFactoryImpl not found
返回做IO数目最多的50条语句以及它们的执行计划。
select top 50
(total_logical_reads/execution_count) as avg_logical_reads,
(total_logical_writes/execution_count) as avg_logical_writes,
(tot
The CUDA 5 Release Candidate is now available at http://developer.nvidia.com/<wbr></wbr>cuda/cuda-pre-production. Now applicable to a broader set of algorithms, CUDA 5 has advanced fe
Essential Studio for WinRT界面控件包含了商业平板应用程序开发中所需的所有控件,如市场上运行速度最快的grid 和chart、地图、RDL报表查看器、丰富的文本查看器及图表等等。同时,该控件还包含了一组独特的库,用于从WinRT应用程序中生成Excel、Word以及PDF格式的文件。此文将对其另外一个强大的控件——网格控件进行专门的测评详述。
网格控件功能
1、
Project Euler是个数学问题求解网站,网站设计的很有意思,有很多problem,在未提交正确答案前不能查看problem的overview,也不能查看关于problem的discussion thread,只能看到现在problem已经被多少人解决了,人数越多往往代表问题越容易。
看看problem 1吧:
Add all the natural num
Adding id and class names to CMenu
We use the id and htmlOptions to accomplish this. Watch.
//in your view
$this->widget('zii.widgets.CMenu', array(
'id'=>'myMenu',
'items'=>$this-&g
Given a collection of integers that might contain duplicates, nums, return all possible subsets.
Note:
Elements in a subset must be in non-descending order.
The solution set must not conta