小编inj*_*eer的帖子

的用法?在 jsonb 上的本机 SQL 查询中

我需要针对 Postgres 列触发选择查询jsonb

entityManager.createNativeQuery(
 "select * from table where jsonbcol -> 'usernames' ? :un"
).setParameter("un", userName).getResultList()
Run Code Online (Sandbox Code Playgroud)

运行时抛出异常:

org.hibernate.engine.query.ParameterRecognitionException: Mixed parameter strategies - 
use just one of named, positional or JPA-ordinal strategy
Run Code Online (Sandbox Code Playgroud)

我尝试像\\?和 一样逃避??,但这没有帮助。

如何正确地进行该调用?

java postgresql hibernate jpa jsonb

7
推荐指数
1
解决办法
1616
查看次数

用于 Map > 类绑定的 Groovy AS 关键字

给定以下课程:

class A {
    B b
    int data
    int data2
}
class B {
    C c
    String data
}
class C {
    Date data
}
Run Code Online (Sandbox Code Playgroud)

该代码工作正常:

Date now = new Date()
def a = [ data:42, data2:84, b:[ data:'BBB', c:[ data:now ] ] ] as A
assert a.b.c.data == now
assert a.data == 42
assert a.data2 == 84
Run Code Online (Sandbox Code Playgroud)

现在,如果我省略data2:84,代码仍然可以正常工作,当然除了最后一个assert

但!如果我“拼错”属性名称,例如:

def a = [ data:42, data22:84, b:[ data:'BBB', c:[ data:now ] ] ] as A
Run Code Online (Sandbox Code Playgroud)

我越来越 …

groovy casting

5
推荐指数
1
解决办法
2053
查看次数

对于某些任务,Gradle 执行会冻结 3 分钟

我有 2 个相对简单的 Gradle 6.1.1 配置,一个是使用https://plugins.gradle.org/plugin/com.github.node-gradle.node来构建一个 React 应用程序,另一个是基于https: //plugins.gradle.org/plugin/com.bmuschko.tomcat并在嵌入式 tomcat 中运行一个简单的 wicket 应用程序。

npm 任务的第一个配置是:

apply plugin: 'com.github.node-gradle.node'
node {
    version = '12.16.0'
    download = true
    workDir = file "$project.buildDir/nodejs"
}

task "npmBuild"( type:NpmTask ) {
    args = [ 'run', 'build' ]
}
Run Code Online (Sandbox Code Playgroud)

并在 Windows 10 中产生以下输出:

>gradlew.bat npmBuild
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :npmBuild

> layer-selection@0.1.0 build .....
> react-scripts build

Creating an optimized production build...
Compiled with warnings. …
Run Code Online (Sandbox Code Playgroud)

java tomcat gradle node.js embedded-tomcat

5
推荐指数
1
解决办法
287
查看次数

如何将字体大小设置为“更大”或系统默认值的 140%

我想为我的用户提供一种可能性,以<Text/>比系统默认值更大的字体大小显示某些元素。该文档仅提供了该样式的编号。

我想使用 web-css“大”或“更大”值或可能使用原始字体大小的140% 显示文本。

我发现了一些关于 SO 和 3rd 方库的问题,比如响应字体大小,但它们似乎都与我无关。

做我想做的最简单的方法是什么?

javascript font-size react-native

5
推荐指数
1
解决办法
202
查看次数

在 Mapbox-GL React Native 中获取“地图”对象

我有这样的代码:

\n
import React, { Component } from 'react'\nimport MapboxGL from '@react-native-mapbox-gl/maps'\n\nMapboxGL.setAccessToken( 'xxxx' )\n\nexport default class DebugMap extends Component {\n\n  render() {\n    return <View style={{ flex: 1}}>\n        \n      <MapboxGL.MapView\n          ref={(c) => (this.map = c)}\n          onPress={v => this.map.moveTo( 40, 10 )}\n          style={{flex: 1}}>\n\n          <MapboxGL.Camera\n            zoomLevel={10}\n            centerCoordinate={[50, 20]}\n          />\n        </MapboxGL.MapView>\n\n    </View>\n  }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

地图通常显示为以 为中心50, 20,但如果我按下它,则会引发错误:

\n
TypeError: _this3.map.moveTo is not a function. (In '_this3.map.moveTo(48, 11)', '_this3.map.moveTo' is undefined)\n
Run Code Online (Sandbox Code Playgroud)\n

我缺少什么?

\n

更新:

\n

如果我console.info( 'load map', this.map ) …

javascript react-native mapbox-gl-js

5
推荐指数
1
解决办法
1473
查看次数

React-Native-SVG:在 Android 模拟器中像素化的蒙版元素

在我的应用程序中,我有以下代码:

    <Svg width={W} height={H} viewBox={viewBox} style={style} preserveAspectRatio="none">
      <Defs>
        <Mask id="mask" x={0} y={0} width={W} height={H} maskUnits="userSpaceOnUse" maskContentUnits='userSpaceOnUse'>
          <Nested name="Path" animated d={path} stroke="white" strokeLinejoin="round" strokeWidth={10} strokeDasharray="5 60" strokeDashoffset={pathOffset}/>
        </Mask>
      </Defs>

      <G mask="url(#mask)">
        <Nested name="Path" d={path} stroke="orange" strokeLinejoin="round"/>
        {fields.map( f => <Nested key={f.id} {...f}/>)}
      </G>

    </Svg>
Run Code Online (Sandbox Code Playgroud)

其中是、和其他 RN-SVG 元素Nested的委托。PathCircle

现在,如果G@mask删除了,Android 模拟器或真实设备上的元素将如下所示:

在此输入图像描述

它的G@mask显示精度降低/像素化/模糊:

在此输入图像描述

我准备了一份小吃 -> https://snack.expo.dev/@injecteer/react-native-svg-mask,在网络模式下,带有动画的蒙版看起来很好(底线):

在此输入图像描述

如何完全精确地显示屏蔽元素?我缺少什么?

javascript svg react-native react-native-svg

5
推荐指数
0
解决办法
168
查看次数

Groovy或Java相当于sumproduct?

在我自己编写之前,有没有人知道Groovy或Java是否预先构建了类似于Excel的sumproduct函数的东西?

sumproduct的准语法是这样的

def list1 = [2,3,4]
def list2 = [5,10,20]

SUMPRODUCT(list1, list2 ...) = 120
Run Code Online (Sandbox Code Playgroud)

你会得到120((2*5)+(3*10)+(4*20)= 120)

groovy

4
推荐指数
1
解决办法
651
查看次数

是否可以在Projections,Criteria,Grails中使用聚合函数和属性?

我正在使用Grails Criteria(类似于hibernate标准)来获取给定表中每个部门中获得最高分的学生列表.而我想要的只是Name,DivisionGrade领域.

Name | Division | Grade | Std_id
---------------------------------
AA1  | A        |  2     | 1
AA2  | A        |  4     | 2
BB1  | B        |  2     | 3
BB2  | B        |  5     | 4
Run Code Online (Sandbox Code Playgroud)

我想要的结果是

Name | Division | Grade |
--------------------------
AA2  | A        |  4     |
BB2  | B        |  5     | 
Run Code Online (Sandbox Code Playgroud)

如果我使用以下标准

    def criteria = Student.createCriteria()
    def resultlt = criteria.list {
        projections {
            groupProperty('divison')
            max('grade') …
Run Code Online (Sandbox Code Playgroud)

grails hibernate criteria hibernate-criteria nhibernate-projections

4
推荐指数
1
解决办法
766
查看次数

Vert.x 事件总线达到限制时的行为

我对事件总线/ Hazelcast 的工作原理缺乏一点了解。

想象一下消费者和生产者 Verticle 通过集群 EB 进行通信的情况。消耗部分是进行CPU/内存/IO密集型计算。

当在某个时刻由于负载而消费者无法立即处理消息时,会发生什么?

消息是否会在环形缓冲区内排队并最终在稍后处理(考虑到 NettySingleThreadEventLoop根据vert.x 中事件总线的大小限制为 20 亿条)?达到上限后会被丢弃吗?

一般来说,只要集群中没有组件崩溃, EB 中的消息是否可以被认为是持久的并且具有传递保证?

hazelcast vert.x vertx-eventbus

4
推荐指数
1
解决办法
1489
查看次数

SwipeRefreshLayout阻止水平滚动的RecyclerView

我的设置很简单:

<android.support.v4.widget.SwipeRefreshLayout
     android:id="@+id/swiperefresh"
     android:layout_width="match_parent"
     android:layout_height="match_parent" >

     <android.support.v7.widget.RecyclerView
         android:id="@+id/recyclerView"
         android:layout_width="match_parent"
         android:layout_height="220dp"/>

</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

内容onCreate():

layoutManager = new LinearLayoutManager( this );
layoutManager.setOrientation( LinearLayoutManager.HORIZONTAL );
topTopicRecyclerView.setLayoutManager( layoutManager );
Run Code Online (Sandbox Code Playgroud)

现在,当我向左或向右滑动recyclelerView并且滑动角度不是完全水平时,SwipeRefreshLayout会跳入并接管滚动控件.这会导致recyclerView内部出现恼人的视觉"打嗝".

如果禁用SwipeRefreshLayout,一切都很好.

那么,如何在RecyclerView的区域上停用SwipeRefreshLayout的滚动控件?

android swiperefreshlayout android-recyclerview

3
推荐指数
2
解决办法
2581
查看次数

Groovy 的 trampoline() 使递归执行速度慢得多 - 为什么?

我正在试验递归:

def fac
//fac = { int curr, res = 1G -> 1 >= curr ? res : fac( curr - 1, res * curr ) }
fac = { int curr, res = 1G -> 1 >= curr ? res : fac.trampoline( curr - 1, res * curr ) }
fac = fac.trampoline()

def rnd = new Random()

long s = System.currentTimeMillis()

100000.times{ fac rnd.nextInt( 40 ) }

println "done in ${System.currentTimeMillis() - s} ms / ${fac(40)}"
Run Code Online (Sandbox Code Playgroud)

如果我像这样使用它,我会得到这个:

在 …

recursion groovy trampolines

3
推荐指数
1
解决办法
267
查看次数

具有常规类的 MapStruct

我想在带有 gradle 的 groovy 类上使用 Mapstruct 映射器。build.gradle 中的配置看起来像 Java 项目中的配置。

dependencies {
    ...
    compile 'org.mapstruct:mapstruct:1.4.2.Final'

    annotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final'
    testAnnotationProcessor 'org.mapstruct:mapstruct-processor:1.4.2.Final' // if you are using mapstruct in test code
}
Run Code Online (Sandbox Code Playgroud)

问题是没有生成映射器的实现类。我还尝试为 groovy 编译任务应用不同的选项,但它不起作用。

compileGroovy {
    options.annotationProcessorPath = configurations.annotationProcessor
    // if you need to configure mapstruct component model
    options.compilerArgs << "-Amapstruct.defaultComponentModel=default"
    options.setAnnotationProcessorGeneratedSourcesDirectory( file("$projectDir/src/main/generated/groovy"))
}
Run Code Online (Sandbox Code Playgroud)

有谁知道 Mapstruct 是否可以与 groovy 类一起工作以及我必须如何配置它?

groovy mapstruct

0
推荐指数
1
解决办法
883
查看次数