小编Edg*_*rka的帖子

Java hibernate Restriction.ne不包含null的实体

我尝试使用条件获取列表Restrictions.ne("status","ERROR")但是方法返回没有实体的列表status is null.

public List<Match_soccer> getDayMatches(Date day){
    //Match_soccer where date between start and end dates and status != null
    Criteria criteria = session.createCriteria(Match_soccer.class);
    criteria.add(Restrictions.between("start", day, DateJobs.addnHours(DateJobs.nextDay(day), 3)));
    criteria.add(Restrictions.ne("status","ERROR"));
    return criteria.list();
}
Run Code Online (Sandbox Code Playgroud)

java hibernate

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

我应该用哪种设计模式来设置竞赛点数?

我有一个类,AthleticCompetitionResults并希望创建一个类,方法返回AthleticCompetitionResults从行初始化的对象,例如

Siim Susi; 12.61; 5.00; 9.22; 1.50; 60.39; 16.43; 21.60; 2.60; 35.81; 5.25.72

Siim Susi2; 12.61; 5.00; 9.22; 1.50; 60.39; 16.43; 21.60; 2.60; 35.81; 5.25.72

Jaana Lind; 13.75; 4.84; 10.12; 1.50; 68.44; 19.18; 30.85; 2.80; 33.88; 6.22.75

public class AthleticCompetitionResults {
  private Athletic athletic;
  private float resultM100;
  private float resultLongJump;
  private float resultShotPut;
  private float resultHighJump;
  private float resultM400;
  private float resultHurdles110m;
  private float resultDiscusThrow;
  private float resultPoleVault;
  private float resultJavelinThrow;
  private float resultM1500;
  private int …
Run Code Online (Sandbox Code Playgroud)

java design-patterns software-design

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

如何使用ui.router模块通过url将数组传递给AngularJS应用程序

我使用Angular 1.5和ui.router模块,并希望将int数组传递到app throw url.www.example.com/#/filter?[1,2,5]或www.example.com/#/filter/[1,2,5]或其他内容.

.state('cats', {
             url: '/filter?catsIds', // or /filter/{catsIds}
             templateUrl:'cats.html',
             controller: 'catsCtrl'
         })
Run Code Online (Sandbox Code Playgroud)

目标:

app.controller('catsCtrl',function($stateParams){
    console.log(Array.isArray($stateParams.catsIds)) // goal true
    ...
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-router

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

Git .gitignore不使用日志文件

我有git存储库/var/www/html/projectx.我的目标是告诉git忽略两个文件 /var/www/html/projectx/error.log/var/www/html/projectx/requsets.log.

我尝试添加.gitignore文件

[git@x]$ cd /var/www/html/projectx
[git@x projectx]$ nano .gitignore
Run Code Online (Sandbox Code Playgroud)

.gitignore:

*~
*.log
Run Code Online (Sandbox Code Playgroud)

git

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

将cheerio模块导入TypeScript应用

我尝试导入cheeriotypescript基于我的应用程序。

import {cheerio}  from 'cheerio';
console.log(cheerio); //undefined
Run Code Online (Sandbox Code Playgroud)

从package.json:

...
"@types/cheerio": "^0.22.5
...
Run Code Online (Sandbox Code Playgroud)

typescript cheerio

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

onfiguration.devtool 应该匹配模式 "^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$"

我正在迁移webpack 4webpack 5.

config/webpack.js 已:

`开发工具:是生产?“隐藏源映射”:“廉价模块评估源映射”

迁移后出错:

onfiguration.devtool 应该匹配模式“^(inline-|hidden-|eval-)?(nosources-)?(cheap-(module-)?)?source-map$”。

看起来新的webpack不喜欢条件,因为如果我更改为:

devtool: 'hidden-source-map'

错误消失了。

webpack

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

温斯顿记录器不写入文件

我想winston在应用程序中使用记录器node将错误记录到文件中。但winston不写入文件。

var logger = new (winston.Logger)({
             transports: [
                new (winston.transports.Console)(),
                new (winston.transports.File)({ filename: 'somefile.log' })
              ]
            });

 logger.error('test');
Run Code Online (Sandbox Code Playgroud)

文件somefile.log已创建但为空。

javascript node.js winston

2
推荐指数
1
解决办法
5510
查看次数

如何从 js 客户端将对象数组传递给 graphql 查询

我想传递给服务器数组的对象抛出graphqlAPI。

我对架构的查询:

export const schema = buildSchema(`
  type Query {
    statistics(
      modelId: String
      picksEnds: [PickEnd]        
    )
  }: Statistics
  type PickEnd {
    end: String
    limit: float
  } 
  ...
`)
Run Code Online (Sandbox Code Playgroud)

我在客户端基于 js 的查询:

 const createStatisticsQuery = (...) => {
     return `query {
             statistics(
               modelId: "${modelId}", 
               picksEnds: ${JSON.stringify(myEnds)}
             ) ...
Run Code Online (Sandbox Code Playgroud)

但出现错误graphql

消息:“语法错误:预期名称,找到字符串“end””

请求负载中的片段:

{"query":"查询 {\n 统计信息(\n modelId: \"5ca0f4afb88b3a2e006faa0d\",\n picksEnds: [{\"end\":\"home\"},{\"end\":\"绘制\"},{\"end\":\"away\"},{\"end\":\"under\",\"limit\":0.5},{\"end\":\"超过\",\"限制\":0.5},{\"结束\":\"低于\",\"限制\":1.5 ...

javascript graphql

2
推荐指数
1
解决办法
7959
查看次数

如果 junit 测试失败,是否可以打印字段值?

我刚刚开始使用 junit/单元测试工具。现在我感受到了它的好处 :) 如果 junit 测试失败,是否可以打印字段值?

\n\n

我的方法尝试实现 INT(A(D \xe2\x80\x94 B)^C):

\n\n
public static int countFieldEventPoints(PointsCountingTableRow row,float centimetres){\n    float temp = row.getA()*(float)Math.pow((centimetres - row.getB()),row.getC());\n    return roundUP(temp);\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的测试:

\n\n
public void testCountlongJumpEventPoints(){\n    PointsCountingTableRow row = Tables.get2001table().getLongJump();\n    float cm = 736f;\n    assertEquals(900,PointCounterService.countFieldEventPoints(row,cm));\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

控制台打印:

\n\n
java.lang.AssertionError: \nExpected :900\nActual   :901\n
Run Code Online (Sandbox Code Playgroud)\n\n

向上取整的方法(我感觉有问题):

\n\n
private static int roundUP(double floatNumber){\n    return (int) Math.round(floatNumber + .5);\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

行类:

\n\n
public class PointsCountingTableRow {\nprivate float A;\nprivate float B;\nprivate float C;\n\n\npublic PointsCountingTableRow(float a, float b, float c) …
Run Code Online (Sandbox Code Playgroud)

java junit unit-testing

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

TypeScript 错误 TS2339:类型“Window”上不存在属性“app”

我尝试在我的旧 AngularJS 项目上开始使用 TypeScript 2.4.1。首先,我尝试将我的简单控制器重构为 ts。在控制器上,我在编译过程中使用匿名函数获取Error:(35, 11) TS2339:Property 'app' does not exist on type 'Window'.

  (function (app) {
    'use strict';
    app.ReservationModule.controller('ItineraryController', ItineraryController);

    ItineraryController.$inject = [
        'SeatMapService',
        'SeatMapSegments'
    ];

    /**
     *  Controlling interaction between seatMap service and Itinerary view.
     */
    function ItineraryController(SeatMapService:any, SeatMapSegments:any) {

        const vm = this;
        vm.deselectService = deselectService;
        vm.show = show;

        /**
         * Deselect traveller seat on seatMap service by segment.
         */
        function deselectService(traveller, segment) {
            SeatMapService.deselectService(traveller, segment);
        }

        /**
         * Returns true if segment has new …
Run Code Online (Sandbox Code Playgroud)

angularjs typescript

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

Java Hibernate实体未正确连接(双向)

我有两个Java HibernateoneToMany关系的实体.我也有Spring控制器和AngularJS前端.当我尝试/cars/getCarsChrome浏览器中,我得到网络状态失败.Eclipse停止工作(冻结).

@Entity
@Table(name="auto")
public class Make {
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private int id;

  @Column(length = 100)
  private String make;

  @OneToMany(fetch = FetchType.LAZY, mappedBy = "make")
  private List<Model> models = new ArrayList<Model>(0);

  public String getMake() {
    return make;
  }

  ...

}
Run Code Online (Sandbox Code Playgroud)

@Entity
@Table(name="models")
public class Model {
  @Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  private int id;

  @Column(length = 100)
  private String model;

  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "fk_maker") 
  private Make make;

  public …
Run Code Online (Sandbox Code Playgroud)

java hibernate

-1
推荐指数
1
解决办法
702
查看次数