我将一个值存储为我的集合中的java.util.Date(),但是当我查询获取两个特定日期之间的值时,我最终得到的值超出了该范围.这是我的代码:
插入
BasicDBObject object = new BasicDBObject();
...
object.put("dateAdded", new java.util.Date());
collection.insert(object);
Run Code Online (Sandbox Code Playgroud)
查询
BasicDBObject query = new BasicDBObject();
query.put("dateAdded", new BasicDBObject("$gte", fromDate));
query.put("dateAdded", new BasicDBObject("$lte", toDate));
collection.find(query).sort(new BasicDBObject("dateAdded", -1));
Run Code Online (Sandbox Code Playgroud)
当我在Wed Jul 27 16:54:49 EST 2011和之间查询Wed Jul 27 16:54:49 EST 2011(基本上是fromDate = toDate)时,我得到的日期对应的对象Tue Jul 26 09:43:37 EST 2011绝对不可能.我在这里错过了什么?
我一直在四处寻找如何将MongoDB与Solr结合使用,这里的一些问题有部分反应,但没有什么真正具体的(更像是理论).在我的应用程序中,我将在MongoDB中存储大量的文档(可能高达数亿),我想对这些文档的某些属性实现全文搜索,所以我猜Solr是最好的方法这个.
我想知道的是我应该如何配置/执行所有内容以使其具有良好的性能?现在,这就是我做的事(我知道它不是最优的):
1-在MongoDB中插入对象时,我将其添加到Solr
SolrServer server = getServer();
SolrInputDocument document = new SolrInputDocument();
document.addField("id", documentId);
...
server.add(document);
server.commit();
Run Code Online (Sandbox Code Playgroud)
2-当更新对象的属性时,由于Solr不能只更新一个字段,首先我从MongoDB中检索对象然后用对象和新属性的所有属性更新Solr索引并执行类似的操作
StreamingUpdateSolrServer update = new StreamingUpdateSolrServer(url, 1, 0);
SolrInputDocument document = new SolrInputDocument();
document.addField("id", documentId);
...
update.add(document);
update.commit();
Run Code Online (Sandbox Code Playgroud)
3-查询时,首先查询Solr,然后在检索文档列表时,SolrDocumentList我会查看每个文档,并且:
4-删除时,我还没有完成那部分,并且不确定如何在Java中完成
那么有人建议如何以更有效的方式为这里描述的每个场景做到这一点?喜欢这样做的过程,当在Solr中有大量文档并一次添加一个文档时,它不会花费1小时来重建索引?我的要求是用户可能希望一次添加一个文档,我希望他们能够立即检索它
我最近经常遇到一个烦人的例外,经过对谷歌和这个论坛的一些研究后,我仍然没有找到可以解决我的问题的答案.
这是事情 - 有时,我尝试使用hibernate更新或创建一个新对象时出现以下错误:
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.
at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1186)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:696)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694)
Run Code Online (Sandbox Code Playgroud)
真正奇怪的是,有时用方法更新对象时getHibernateTemplate().saveOrUpdate(object);它会起作用,但有时候使用相同的对象并通过调用相同的方法它不起作用,但它似乎取决于我如何获得对象第一名.
示例:假设我有一个包含3个字段的表:id,type,length.可能发生的是,如果我通过id获取对象并更新长度,那么它将起作用.如果我按类型获取并更新长度,那么它将无法工作.所以到目前为止我一直在做的是避免这个问题,就是获取对象后面不会引起问题的方法,但是尝试找到一种有效的方法会变得越来越烦人.
此外,现在我在尝试创建一个对象(但不是所有对象,仅在一个特定的表上)时遇到此异常,并且无法找到解决方法的方法.我试图@Transactional(readOnly = false)在事务中添加但它没有改变任何东西,显示模式就是说我不是只读的.
有什么建议?
编辑7月26日:这里有一些与hibernate相关的配置
<property name="hibernateProperties">
<props>
<prop key="jdbc.fetch_size">20</prop>
<prop key="jdbc.batch_size">25</prop>
<prop key="cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="connection.autoReconnect">true</prop>
<prop key="connection.autoReconnectForPools">true</prop>
<prop key="connection.is-connection-validation-required">true</prop>
</props>
</property>
Run Code Online (Sandbox Code Playgroud)
如果它可以帮助
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="execute*">PROPAGATION_REQUIRED</prop>
<prop key="add*">PROPAGATION_REQUIRED</prop> …Run Code Online (Sandbox Code Playgroud) 我YuvImage用来压缩android.hardware.Camerajpeg 的feed.从那时起,我一直skia onFlyCompress在logcat中看到消息,这完全污染了它.有没有办法禁用此消息?我知道我可以过滤logcat输出,但这意味着一直到处都做,这不是一个修复,而是一个解决方法.我根本不想要打印这些消息
我想在中创建一个可拖动/可调整大小/可旋转的组件Ionic2.pan并且pinch事件工作得很好,但rotate有一个奇怪的行为:如果我用两个手指触摸组件,但没有进行任何旋转,我仍然会得到一个rotation大约15到30度的数字,使组件旋转.我不知道这是一个已知问题还是与屏幕的灵敏度有关.我用于组件的代码是这样的:
import { Component, ElementRef, Input, Renderer2 } from '@angular/core';
import { DomController, Gesture } from 'ionic-angular';
const defaultScale: number = 1;
const defaultRotation: number = 0;
@Component({
selector: 'draggable',
template: `
<ng-content></ng-content>
`
})
export class DraggableComponent {
@Input()
private position: {
x: number;
y: number;
};
@Input()
private dimensions: {
width: number;
height: number;
};
@Input()
private transform: {
scale: number;
rotation: number;
};
@Input()
protected container: any; …Run Code Online (Sandbox Code Playgroud) 在运行一些云函数时,我有时会收到错误:
"The request was aborted because there was no available instance."
Run Code Online (Sandbox Code Playgroud)
我看到其他问题也出现类似的错误,但对于 Cloud Run,您可以指定可用实例的数量,但 Cloud Function 似乎没有这样的事情。那么如何解决这个问题呢?
我可以在配额页面看到后台功能有限制,但 HTTP 功能没有限制。我通过 HTTP 调用 lambda 函数,它部署在us-central1
我有一个带有属性的简单<select></select>内部,例如:<div>ng-show
<div ng-show="edit">
<select ng-options="key as value in VALUES"></select>
</div>
Run Code Online (Sandbox Code Playgroud)
现在出于某种原因,当我点击select打开它时,它会闪烁,就像选择是非常快速地打开/关闭一样.有时会眨眼两次,有时甚至更多.我曾经使用过select有角度的盒子而且从来没有这个.
我发现了导致它的原因.它出现的完整形式如下:
<form class="mb-lg" name="formValidate" ng-init="addCreate = '.action_add'" novalidate="" role="form">
<label class="radio-inline c-radio">
<input id="action_add" name="add_create" ng-model="addCreate" required="required" type="radio" value=".action_add">
<span class="fa fa-circle"></span>
Add to existing
</label>
<div class="form-group has-feedback">
<select class="form-control" name="selected" ng-disabled="addCreate != '.action_add'" ng-model="selected" ng-options="p as p.name for p in portfolios | filter : {'update?': true}" ng-required="addCreate == '.action_add'" required="required"></select>
</div>
<label class="radio-inline c-radio ng-binding">
<input id="action_create" name="add_create" ng-model="addCreate" …Run Code Online (Sandbox Code Playgroud) 我有一个Ionic项目,我想要显示一个视频,并在其上面显示cordova的内容WebView.要WebView在视频视图的顶部透明,我在插件中使用:
webView.getView().setBackgroundColor(0x00000000);
((ViewGroup) webView.getView()).bringToFront();
Run Code Online (Sandbox Code Playgroud)
将VideoView被初始化,并添加在FrameLayout这样的:
FrameLayout containerView = (FrameLayout) cordova.getActivity().findViewById(1);
if (containerView == null) {
containerView = new FrameLayout(cordova.getActivity().getApplicationContext());
containerView.setId(1);
containerView.setBackgroundColor(Color.BLACK);
FrameLayout.LayoutParams containerLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
cordova.getActivity().addContentView(containerView, containerLayoutParams);
videoView = new VideoView(cordova.getActivity());
videoView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
containerView.addView(videoView);
MediaPlayer player = new MediaPlayer();
player.setOnPreparedListener(this);
player.setOnCompletionListener(this);
player.setOnErrorListener(this);
final SurfaceHolder holder = videoView.getHolder();
holder.setKeepScreenOn(true);
holder.addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
player.setDisplay(holder);
try {
player.prepare();
} catch (Exception e) {
e.printStackTrace();
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用Bamboo 6.0.3 build 60004,我为Bamboo安装2.1.0了官方Artifactory插件的版本.
该build.gradle项目的外观如下:
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
...
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}
artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
afterEvaluate {
androidJavadocs.classpath += files(android.libraryVariants.collect { variant ->
variant.javaCompile.classpath.files
})
}
publishing {
publications {
android.buildTypes.all { variant -> …Run Code Online (Sandbox Code Playgroud) 我使用以下代码在Docker-Compose上运行Wordpress docker-compose.yml:
version: '2'
services:
db_wordpress:
image: mysql:5.7
volumes:
- db_wordpress_data:/var/lib/mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: pwd
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: pwd
wordpress:
image: wordpress:latest
volumes:
- ./wp-content:/var/www/html/wp-content
restart: unless-stopped
expose:
- 80
depends_on:
- db_wordpress
environment:
WORDPRESS_DB_HOST: db_wordpress:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: pwd
WORDPRESS_DEBUG: 1
WORDPRESS_CONFIG_EXTRA: |
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of errors and warnings
define('WP_DEBUG_DISPLAY', false);
// Handle subpath /blog
define('WP_HOME','https://www.example.com/blog');
define('WP_SITEURL','https://www.example.com/blog');
$$_SERVER['REQUEST_URI'] = '/blog' . $$_SERVER['REQUEST_URI'];
nginx:
image: …Run Code Online (Sandbox Code Playgroud)