问:
Can't bind to 'someProperty' since it isn't a known property of 'someComponent' in Angular 5
In Angular 5 app I'm using following component:

```<code>import {
  Component,
  OnInit,
  Input,
  forwardRef
} from '@angular/core';
import {
  ControlValueAccessor,
  NG_VALUE_ACCESSOR
} from '@angular/forms';

@Component({
  selector: 'int-switcher',
  templateUrl: './switcher.component.html',
  styleUrls: ['./switcher.component.scss'],
  providers: [
    {
      provide: NG_VALUE_ACCESSOR,
      useExisting: forwardRef(() => SwitcherComponent),
      multi: true
    }
  ]
})
export class SwitcherComponent implements OnInit, ControlValueAccessor {
  @Input() _value: boolean;
  get value() {
      return this._value;
  }
  set value(val) {
      this._value = val;
      this.propagateChange(this._value);
  }
  constructor() {}

  ngOnInit() {}
  writeValue(value: any): void {
    if (value !== undefined) {
      this._value = value;
    }
  }
  propagateChange = (_: any) => {};
  registerOnChange(fn: any): void {
      this.propagateChange = fn;
  }
  registerOnTouched(fn: any): void {}
  toggleValue() {
    this.value = !this.value;
    this.propagateChange(this.value);
  }
}
</code>```

And template:

```<code><div class="switcher" (click)="toggleValue()">
  <div class="switcher-label"><ng-content></ng-content></div>
  <div class="switch">
    <input class="switch-input" type="checkbox" [(ngModel)]="value">
    <label class="switch-label switch-paddle"></label>
  </div>
</div>
</code>```

I'm trying to set the value for this property, but I get the following error:

Can't bind to 'value' since it isn't a known property of
  'int-switcher'.

If 'int-switcher' is an Angular component and it has 'value' input, then verify that it is part of this module.

If 'int-switcher' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component
  to suppress this message.

To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

I have tried to do the following:

```<code><int-switcher name="groupHotel" formControlName="groupHotel" (click)="setGrouping($event)" [value]="isGrouped">
</code>```

and in ngInit:

```<code>  isGrouped: boolean;
  ngOnInit(): void {
    this.isGrouped = true;
}
</code>```

Why can't I bind to this property?

答:
Your @Input is set to underscore value, not @Input value, your issue lies there. You want to make sure your @Input <name> matches with what you use when you use your component/directive.

Simplest untested example;

```<code>import { Component } from '@angular/core';

@Component({
  selector: 'color-component',
  template: `<div>{{color}}</div>`
})
export class ColorComponent {
  @Input() color: string;
}
</code>```

then when you use the component

```<code><color-component [color]="blue"</color-component>
</code>```

Body:
In Angular 5 app I'm using following component:

import {
  Component,
  OnInit,
  Input,
  forwardRef
} from '@angular/core';
import {
  ControlValueAccessor,
  NG_VALUE_ACCESSOR
} from '@angular/forms';

@Component({
  selector: 'int-switcher',
  templateUrl: './switcher.component.html',
  styleUrls: ['./switcher.component.scss'],
  providers: [
    {
      provide: NG_VALUE_ACCESSOR,
      useExisting: forwardRef(() => SwitcherComponent),
      multi: true
    }
  ]
})
export class SwitcherComponent implements OnInit, ControlValueAccessor {
  @Input() _value: boolean;
  get value() {
      return this._value;
  }
  set value(val) {
      this._value = val;
      this.propagateChange(this._value);
  }
  constructor() {}

  ngOnInit() {}
  writeValue(value: any): void {
    if (value !== undefined) {
      this._value = value;
    }
  }
  propagateChange = (_: any) => {};
  registerOnChange(fn: any): void {
      this.propagateChange = fn;
  }
  registerOnTouched(fn: any): void {}
  toggleValue() {
    this.value = !this.value;
    this.propagateChange(this.value);
  }
}

And template:

<ng-content></ng-content>

    <input class="switch-input" type="checkbox" [(ngModel)]="value">

I'm trying to set the value for this property, but I get the following error:

Can't bind to 'value' since it isn't a known property of
  'int-switcher'.

If 'int-switcher' is an Angular component and it has 'value' input, then verify that it is part of this module.

If 'int-switcher' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component
  to suppress this message.

To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

I have tried to do the following:

<int-switcher name="groupHotel" formControlName="groupHotel" (click)="setGrouping($event)" [value]="isGrouped">

and in ngInit:

  isGrouped: boolean;
  ngOnInit(): void {
    this.isGrouped = true;
}

Why can't I bind to this property?

Body:
Your @Input is set to underscore value, not @Input value, your issue lies there. You want to make sure your @Input <name> matches with what you use when you use your component/directive.

Simplest untested example;

import { Component } from '@angular/core';

@Component({
  selector: 'color-component',
  template: `<div>{{color}}</div>`
})
export class ColorComponent {
  @Input() color: string;
}

then when you use the component

<color-component [color]="blue"</color-component>


来源: stackexchange

问:
How to center caption in Bootstrap 4 carousel?
I essentially copied the captioned carousel example from the Bootstrap 4 documentation: https://v4-alpha.getbootstrap.com/components/carousel/

However, I cannot seem to achieve a carousel that only has text, where the text is centered...

Here is my code:

My Carousel

        ...is not centered!

    Previous slide

    Next slide

```

Aside from some minor styling, this is what the above code renders:

As you can see, the text is not centered! Per some other questions I found here on StackOverflow, I tried:

Setting .carousel-caption to have margin: 0 auto

Setting .carousel-caption to have position: relative

Setting .carousel-caption to have text-align: center

Wrapping each .carousel-item in a .container and styling to achieve a centered text

None of the solutions have worked, so I ask you all; how can I achieve a horizontally centered carousel with only captions?

Edit: JSFiddle

答:
For carousel with fixed height (e.g.: 400px) this works for me:</p>

```<code>.carousel-caption {
    position: relative;
    left: 0;
    padding-top: 150px; // Set relative to your carousel height
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I essentially copied the captioned carousel example from the Bootstrap 4 documentation: https://v4-alpha.getbootstrap.com/components/carousel/

However, I cannot seem to achieve a carousel that only has text, where the text is centered...

Here is my code:

My Carousel

        ...is not centered!

    Previous slide

    Next slide

Aside from some minor styling, this is what the above code renders:

As you can see, the text is not centered! Per some other questions I found here on StackOverflow, I tried:

Setting .carousel-caption to have margin: 0 auto

Setting .carousel-caption to have position: relative

Setting .carousel-caption to have text-align: center

Wrapping each .carousel-item in a .container and styling to achieve a centered text

None of the solutions have worked, so I ask you all; how can I achieve a horizontally centered carousel with only captions?

Edit: JSFiddle

Body:
For carousel with fixed height (e.g.: 400px) this works for me:

.carousel-caption {
    position: relative;
    left: 0;
    padding-top: 150px; // Set relative to your carousel height
}


问:
Racket: evaluating a tree with arithmetic operators
I want to evaluate a tree with arithmetic operators as symbols. So a tree is:

```<code>(define-struct op-tree (op left right))
</code>```

left and right could either be a number or an 'operator as well. What I have so far:

```<code>(define (eval-op-tree tree)
  (local (
      (define (get-root-op i)
        (cond
          ((symbol=? i '+) +)
          ((symbol=? i '-) -)
          ((symbol=? i '/) /)
          ((symbol=? i '*) *)))
      (define (get-info i)
        (cond
          ((number? i) i)
          ((symbol=? '+ (op-tree-op i)) (+ (get-info (op-tree-left tree)) (get-info (op-tree-right tree))))
          ((symbol=? '- (op-tree-op i)) (- (get-info (op-tree-left tree)) (get-info (op-tree-right tree))))
          ((symbol=? '* (op-tree-op i)) (* (get-info (op-tree-left tree)) (get-info (op-tree-right tree))))
          ((symbol=? '/ (op-tree-op i)) (/ (get-info (op-tree-left tree)) (get-info (op-tree-right tree)))))))
(cond
  ((not (symbol? (op-tree-op tree))) "root has to be an op")
  (else
   ((get-root-op (op-tree-op tree)) (get-info (op-tree-left tree)) (get-info (op-tree-right tree)))))))
</code>```

This seems to work for (make-op-tree 'any-operator any-number any-number but doesn't work for a tree whose length is greater than 1 and the program runs for ever... What do I do wrong?

答:
Yes, I see the problem. You have a couple of minor issues.

You've got two completely independent evaluators; one is nested inside the other. There's no need to have two separate ones.

Move your get-info function outside of that local; it has no dependency on the surrounding function. Or... it shouldn't, anyway. (That's your bug.) After you find your bug, you still have some cleanup to do.

Body:
I want to evaluate a tree with arithmetic operators as symbols. So a tree is:

(define-struct op-tree (op left right))

left and right could either be a number or an 'operator as well. What I have so far:

(define (eval-op-tree tree)
  (local (
      (define (get-root-op i)
        (cond
          ((symbol=? i '+) +)
          ((symbol=? i '-) -)
          ((symbol=? i '/) /)
          ((symbol=? i '*) *)))
      (define (get-info i)
        (cond
          ((number? i) i)
          ((symbol=? '+ (op-tree-op i)) (+ (get-info (op-tree-left tree)) (get-info (op-tree-right tree))))
          ((symbol=? '- (op-tree-op i)) (- (get-info (op-tree-left tree)) (get-info (op-tree-right tree))))
          ((symbol=? '* (op-tree-op i)) (* (get-info (op-tree-left tree)) (get-info (op-tree-right tree))))
          ((symbol=? '/ (op-tree-op i)) (/ (get-info (op-tree-left tree)) (get-info (op-tree-right tree)))))))
(cond
  ((not (symbol? (op-tree-op tree))) "root has to be an op")
  (else
   ((get-root-op (op-tree-op tree)) (get-info (op-tree-left tree)) (get-info (op-tree-right tree)))))))

This seems to work for (make-op-tree 'any-operator any-number any-number but doesn't work for a tree whose length is greater than 1 and the program runs for ever... What do I do wrong?


问:
Use UPDATE statement in a CTE expression SQL
I have the following scenario:

I have tickets (=incidents) that have multiple activities.

An incident however can have a child ticket (+ grand child ticket) and so on:

That's why what I want to do, is to add all of the activities of the (grand)children, to the one of its parent.

So:

I began with retrieving all of the sub elements of a single ticket, I used a CTE for this:

```<code>With TicketTree(iID, pID)
as
(
    Select incidentID, parentID FROM incident where incidentID = 1
    UNION ALL
    SELECT incidentID, parentID FROM incident INNER JOIN TicketTree R on parentID = R.iID
)
Select  * from TicketTree
JOIN activity on TicketTree.iID = activity.incidentID
</code>```

The query works and retrieves all of the sub incidents.

My question now is, is it possible to UPDATE the activity table and to set the incidentID of all the children to the one of the parent (using a query)?

I tried:

```<code>UPDATE activity
set incidentID = 1
WHERE incidentID IN(
Select  iID from TicketTree
JOIN activity on TicketTree.iID = activity.incidentID
)
</code>```

It tells me that 11 rows were affected but the activities of the children did not change?

What am I doing wrong?

答:
You can do something like this:</p>

```<code>With TicketTree(iID, pID) as (
      Select incidentID, parentID FROM incident where incidentID = 1
      UNION ALL
      SELECT incidentID, parentID FROM incident INNER JOIN TicketTree R on parentID = R.iID
     )
update activity
    set incidentID = 1
    where incidentID in (select iID in TicketTree);
</code>```

Body:
I have the following scenario:

I have tickets (=incidents) that have multiple activities.

An incident however can have a child ticket (+ grand child ticket) and so on:

That's why what I want to do, is to add all of the activities of the (grand)children, to the one of its parent.

So:

I began with retrieving all of the sub elements of a single ticket, I used a CTE for this:

With TicketTree(iID, pID)
as
(
    Select incidentID, parentID FROM incident where incidentID = 1
    UNION ALL
    SELECT incidentID, parentID FROM incident INNER JOIN TicketTree R on parentID = R.iID
)
Select  * from TicketTree
JOIN activity on TicketTree.iID = activity.incidentID

The query works and retrieves all of the sub incidents.

My question now is, is it possible to UPDATE the activity table and to set the incidentID of all the children to the one of the parent (using a query)?

I tried:

UPDATE activity
set incidentID = 1
WHERE incidentID IN(
Select  iID from TicketTree
JOIN activity on TicketTree.iID = activity.incidentID
)

It tells me that 11 rows were affected but the activities of the children did not change?

What am I doing wrong?

Body:
You can do something like this:

With TicketTree(iID, pID) as (
      Select incidentID, parentID FROM incident where incidentID = 1
      UNION ALL
      SELECT incidentID, parentID FROM incident INNER JOIN TicketTree R on parentID = R.iID
     )
update activity
    set incidentID = 1
    where incidentID in (select iID in TicketTree);


问:
CodeIgniter ActiveRecord Subquery Evalulation
I have an application where I want user items to be assigned in a continuous, ascending order, but only continuous with regards to the user's previously assigned item_ids.

```<code>-- Primary query.
INSERT INTO user_items ( user_id, item_id ) VALUES ( <user_id>, <item_id> ); -- There are more fields, but they are not relevant to this question.

-- Desired item_id value subquery.
SELECT MAX( sq.item_id ) + 1 from ( select item_id from user_items where user_id = {$item_id} ) as sq
</code>```

I have tested the complete query (with the subquery) and the query is valid on the database, but when I use the $this->db->set() method with the $escape parameter equal to FALSE, a zero is inserted every time; it seems the subquery (which is specified as a string) is evaluated before the insert() method is called.

Can I instruct the set() method to place the subquery into generated INSERT query for evaluation on the database?

答:
using it that way will not be a good option / proposition as ther can be parallel queries that can read that data and still get the same value. There can be chances of having duplicate value.

Rather, create a sequence table, store the values of generated IDs in the sequence table. For assigining a new ID, run through the following steps:

lock the sequence table

select, increment the value.

update tne entry with incremented value

release the lock

Use the updated value

That way you can assure unique value for the same.

Body:
I have an application where I want user items to be assigned in a continuous, ascending order, but only continuous with regards to the user's previously assigned item_ids.

-- Primary query.
INSERT INTO user_items ( user_id, item_id ) VALUES ( <user_id>, <item_id> ); -- There are more fields, but they are not relevant to this question.

-- Desired item_id value subquery.
SELECT MAX( sq.item_id ) + 1 from ( select item_id from user_items where user_id = {$item_id} ) as sq

I have tested the complete query (with the subquery) and the query is valid on the database, but when I use the $this->db->set() method with the $escape parameter equal to FALSE, a zero is inserted every time; it seems the subquery (which is specified as a string) is evaluated before the insert() method is called.

Can I instruct the set() method to place the subquery into generated INSERT query for evaluation on the database?


问:
Lookup values via VBA
I need help looking up row D1 and E1 with columns A1:B via VBA. Basically, I'm making Type (column A) as the row headers and transferring Object (column B) to their corresponding Type.

I was able to create a VBA code to do that but I'm just stuck with the lookup function. The only way I can think of is doing this via Vlookup function but I'm pretty sure that there's a better a more efficient way to do this coz using VBA to input the formula on each row would be tedious and troublesome.

I've tried researching about it but it seems that I'm too noob about it. If any of you can post the most comprehensive way on how to do it, I'd really appreciate it.

here's how the code looks so far.

```<code>Set SearchTermData = Worksheets("Search Term Data")
Set Data = Worksheets("Data")

Dim AdGrpCount As Variant, CampHeader As Variant

SearchTermData.[A:B].Copy Data.[A1]

With Data

    [A2:A1048576].Copy [C1]
    [C:C].RemoveDuplicates Columns:=Array(1), Header:=xlNo
    CopyTransposed [C:C].SpecialCells(xlCellTypeConstants), [C1]
    [C2:C1048576].SpecialCells(xlCellTypeConstants).Clear

    AdGrpCount = [B2:B1048576].SpecialCells(xlCellTypeConstants).Count
    CampHeader = [C1:XFD1].SpecialCells(xlCellTypeConstants).Count

            For rowcnt = 2 To AdGrpCount
                check = Application.Match([C1], Cells(rowcnt, 1), 0)
                    If Application.IsNumber(check) Then
                        Cells(rowcnt, 2).Copy Cells(rowcnt, 3)
                    End If
            Next rowcnt
End With
</code>```

答: A very simple way to create this functionality would be, to put the formula =IF($A2=D$1,$B2,"") in cell D2, and to copy this formula to range D2:E15 .

Title: Lookup values via VBA

Body:
I need help looking up row D1 and E1 with columns A1:B via VBA. Basically, I'm making Type (column A) as the row headers and transferring Object (column B) to their corresponding Type.

I was able to create a VBA code to do that but I'm just stuck with the lookup function. The only way I can think of is doing this via Vlookup function but I'm pretty sure that there's a better a more efficient way to do this coz using VBA to input the formula on each row would be tedious and troublesome.

I've tried researching about it but it seems that I'm too noob about it. If any of you can post the most comprehensive way on how to do it, I'd really appreciate it.

here's how the code looks so far.

Set SearchTermData = Worksheets("Search Term Data")
Set Data = Worksheets("Data")

Dim AdGrpCount As Variant, CampHeader As Variant

SearchTermData.[A:B].Copy Data.[A1]

With Data

    [A2:A1048576].Copy [C1]
    [C:C].RemoveDuplicates Columns:=Array(1), Header:=xlNo
    CopyTransposed [C:C].SpecialCells(xlCellTypeConstants), [C1]
    [C2:C1048576].SpecialCells(xlCellTypeConstants).Clear

    AdGrpCount = [B2:B1048576].SpecialCells(xlCellTypeConstants).Count
    CampHeader = [C1:XFD1].SpecialCells(xlCellTypeConstants).Count

            For rowcnt = 2 To AdGrpCount
                check = Application.Match([C1], Cells(rowcnt, 1), 0)
                    If Application.IsNumber(check) Then
                        Cells(rowcnt, 2).Copy Cells(rowcnt, 3)
                    End If
            Next rowcnt
End With


问:
Parsing Base64 json directly into a POJO in a spring MVC controller
code for the controller

```<code>    @RequestMapping(value = "/second", method = RequestMethod.POST,
    consumes = "application/json")
    @ResponseBody
    public void test(@RequestBody RegistrationRequest
    registrationRequest)
    {
       System.out.println(registrationRequest.toString());
    }
</code>```

POJO

```<code>    @Data
    @JsonDeserialize(using = Base64Deserializer.class)
    public class RegistrationRequest {
       @JsonProperty("payment-method-details")
       public PaymentMethodDetails paymentMethodDetails;
       @JsonProperty("customer-details")
       public CustomerDetails customerDetails;
    }
</code>```

CustomerDetails, PaymentMethodDetails are POJO of their own.
I am very new to the Spring MVC concepts, and this is all I have figured out till now but while making the post request from the Postman, it isn't working. What is wrong that I am doing?

I can not maneuver anything how the request is going to come.

Using Base64 deserialiser

Decode base64 encoded JSON to POJO with jackson and spring-boot

答:
It is not clear from the question, about the desired format of the request.

Above code should work fine with a request like this :

```<code>curl -X POST "http://myhost:port/rootPath/second/" -d '{"payment-method-details":"eyJwYXltZW50TWV0aG9kRGV0YWlsc1ZhcjEiOiJzb21lIHRleHQiLCJwYXltZW50TWV0aG9kRGV0YWlsc1ZhcjIiOiJzb21lIHRleHQyIn0=", "customer-details":"eyJjdXN0b21lckRldGFpbHNWYXIxIjoic29tZSB0ZXh0IiwiY3VzdG9tZXJEZXRhaWxzVmFyMiI6InNvbWUgdGV4dDIifQ=="}'
</code>```

This will get the above code working and prints the output.

Note, here eyJjdXN0b21lckRldGFpbHNWYXIxIjoic29tZSB0ZXh0IiwiY3VzdG9tZXJEZXRhaWxzVmFyMiI6InNvbWUgdGV4dDIifQ== decodes to {"customerDetailsVar1":"some text","customerDetailsVar2":"some text2"} in base64 format, similar is the case for other variable.

Body:
code for the controller

    @RequestMapping(value = "/second", method = RequestMethod.POST,
    consumes = "application/json")
    @ResponseBody
    public void test(@RequestBody RegistrationRequest
    registrationRequest)
    {
       System.out.println(registrationRequest.toString());
    }

POJO

    @Data
    @JsonDeserialize(using = Base64Deserializer.class)
    public class RegistrationRequest {
       @JsonProperty("payment-method-details")
       public PaymentMethodDetails paymentMethodDetails;
       @JsonProperty("customer-details")
       public CustomerDetails customerDetails;
    }

CustomerDetails, PaymentMethodDetails are POJO of their own.
I am very new to the Spring MVC concepts, and this is all I have figured out till now but while making the post request from the Postman, it isn't working. What is wrong that I am doing?

I can not maneuver anything how the request is going to come.

Using Base64 deserialiser

Decode base64 encoded JSON to POJO with jackson and spring-boot

Body:
It is not clear from the question, about the desired format of the request.

Above code should work fine with a request like this :

curl -X POST "http://myhost:port/rootPath/second/" -d '{"payment-method-details":"eyJwYXltZW50TWV0aG9kRGV0YWlsc1ZhcjEiOiJzb21lIHRleHQiLCJwYXltZW50TWV0aG9kRGV0YWlsc1ZhcjIiOiJzb21lIHRleHQyIn0=", "customer-details":"eyJjdXN0b21lckRldGFpbHNWYXIxIjoic29tZSB0ZXh0IiwiY3VzdG9tZXJEZXRhaWxzVmFyMiI6InNvbWUgdGV4dDIifQ=="}'

This will get the above code working and prints the output.

Note, here eyJjdXN0b21lckRldGFpbHNWYXIxIjoic29tZSB0ZXh0IiwiY3VzdG9tZXJEZXRhaWxzVmFyMiI6InNvbWUgdGV4dDIifQ== decodes to {"customerDetailsVar1":"some text","customerDetailsVar2":"some text2"} in base64 format, similar is the case for other variable.


问:
Image showing two sizes
I am trying to have one image as a background image. The problem is the image is showing up twice, once at it's original size and then again at a larger size which fills the full width of the page. I'm not sure why they are both showing up. I have set the image to not repeat. The image showing at the larger size resizes when I change a value (ex. height 335px to 900px) but the original size image continues to show on top of the image I just mentioned thatenter code here resizes. How can I get the original size image not to show up. This is my CSS:

```<code>#banner-contact{
    width: 100%;
    height:100px;
    background-image:url('resized-images-logo/contact-page-resized.jpg');
    background-repeat:no-repeat;
    background-size:cover;
    margin:0px;
}

with the following html:

    <div id="banner-contact">
        <img src="resized-images-logo/contact-page-resized.jpg">
    </div>
</code>```

答: Both the img html element and background-image css style result in a shown image. You should be able to remove the img element from the html, and the css style for the div will display your cover image.</p>

Title: Image showing two sizes

Body:
I am trying to have one image as a background image. The problem is the image is showing up twice, once at it's original size and then again at a larger size which fills the full width of the page. I'm not sure why they are both showing up. I have set the image to not repeat. The image showing at the larger size resizes when I change a value (ex. height 335px to 900px) but the original size image continues to show on top of the image I just mentioned thatenter code here resizes. How can I get the original size image not to show up. This is my CSS:

#banner-contact{
    width: 100%;
    height:100px;
    background-image:url('resized-images-logo/contact-page-resized.jpg');
    background-repeat:no-repeat;
    background-size:cover;
    margin:0px;
}

with the following html:


问:
Cordova Error using Cordova-Android 6.2.0 - getFileResources is not a function
I have an ionic/cordova project using:

```<code>cordova-android@6.2.0
cordova-plugin-crosswalk-webview@2.3.0
cordova cli 6.4.0
ionic 1.3.3
</code>```

When I try to add the Android platform, I get the following output

```<code>================

$ ionic platform add android@6.2.0

Adding android project...

Creating Cordova project for the Android platform:

    Path: platforms/android
    Package: com.ionicframework.name
    Name: name
    Activity: MainActivity
    Android target: android-25

Subproject Path: CordovaLib

Android project created with cordova-android@6.2.0
</code>```

Error: cordovaProject.projectConfig.getFileResources is not a function

答:
Do whatever @IonicBurger has said above.
Also make sure that for Cordova based projects, each cordova version has specific dependency on android SDK and android build tools installed.

I am currently using Ionic 3 and I faced the same issue.

Make sure cordova is latest: npm i cordova -g will do the job. Note what version of cordova is installed by checking cordova -v. After that ensure you have installed ionic-native; this usually comes with ionic installation, but it wont harm to installed this again locally with npm i ionic-native --save

See all available platforms: ionic cordova platform list. Some plugins like camera, media etc have very specific cordova requirements (refer here)

When you install a plugin, you may encounter such error sometimes: 'Plugin doesn't support this project's cordova-android version. cordova-android: 6.1.2, failed version requirement: >=6.3.0
Skipping 'cordova-plugin-camera' for android'. Thats okay. This can be resolved by above two steps. Most importantly remember this: Ensure you have latest Android Build Tools and SDK installed.
Please see the following image for more detail:

Note that this answer works best with Windows environment.

Body:
I have an ionic/cordova project using:

cordova-android@6.2.0
cordova-plugin-crosswalk-webview@2.3.0
cordova cli 6.4.0
ionic 1.3.3

When I try to add the Android platform, I get the following output

================

$ ionic platform add android@6.2.0

Adding android project...

Creating Cordova project for the Android platform:

    Path: platforms/android
    Package: com.ionicframework.name
    Name: name
    Activity: MainActivity
    Android target: android-25

Subproject Path: CordovaLib

Android project created with cordova-android@6.2.0

Error: cordovaProject.projectConfig.getFileResources is not a function


问:
How to load and filter data efficiently in SSIS
Need to loading a flat file with an SSIS Package executed in a scheduled job in SQL Server 2016 but it's taking TOO MUCH TIME (like 2/3 hours) just to load data in source then it’s need extra (2/3 hours) time for sort and filter then need similar time to load data in target, the file just has like million rows and it’s not less than 3 GB file approximately. This is driving me crazy, because is affecting the performance of my server.

SSIS package: -My package is just a Data Flow Task that has a Flat File Source and an OLE DB Destination, that’s all -The Data Access Mode is set to FAST LOAD. -Just have 1 indexes in the table. My destination table has 32 columns

Input file:
Input text file has more than 32 columns, surrogate key data may not unique , referenced columns date may not unique , Need to filter them.

Face two problems one is SSIS FlatFile-Source take huge time to load date another one is sort and filter. What to do?

答:
Some Suggestions

1. DROP and Recreate indexes

Add 2 Execute SQL Task; before and after the Data Flow Task, the first drop the index and the second recreate it after that the Data Flow Task is executed successfully

2. Adjust the buffer size

You can read more about buffer sizing in the following Technet article

3. Remove duplicates in SQL server instead of Sort Components

Try to remove the Sort components, and add an Execute SQL Task after the Data Flow Task which run a similar query:

```<code>;WITH x AS
(
  SELECT col1, col2, col3, rn = ROW_NUMBER() OVER
      (PARTITION BY col1, col2, col3 ORDER BY id)
  FROM dbo.tbl
)
DELETE x WHERE rn > 1;
</code>```

4. Use a script component instead of Sort

You have to implement a similar logic to the following answer:

SSIS: Flat File Source to SQL without Duplicate Rows

Some helpful Links

Integration Services: Performance Tuning Techniques

Data Flow Performance Features

Can I delete database duplicates based on multiple columns?

Removing duplicate rows (based on values from multiple columns) from SQL table

Deleting duplicates based on multiple columns

Remove duplicates based on two columns

Body:
Some Suggestions

1. DROP and Recreate indexes

Add 2 Execute SQL Task; before and after the Data Flow Task, the first drop the index and the second recreate it after that the Data Flow Task is executed successfully

2. Adjust the buffer size

You can read more about buffer sizing in the following Technet article

3. Remove duplicates in SQL server instead of Sort Components

Try to remove the Sort components, and add an Execute SQL Task after the Data Flow Task which run a similar query:

;WITH x AS
(
  SELECT col1, col2, col3, rn = ROW_NUMBER() OVER
      (PARTITION BY col1, col2, col3 ORDER BY id)
  FROM dbo.tbl
)
DELETE x WHERE rn > 1;

4. Use a script component instead of Sort

You have to implement a similar logic to the following answer:

SSIS: Flat File Source to SQL without Duplicate Rows

Some helpful Links

Integration Services: Performance Tuning Techniques

Data Flow Performance Features

Can I delete database duplicates based on multiple columns?

Removing duplicate rows (based on values from multiple columns) from SQL table

Deleting duplicates based on multiple columns

Remove duplicates based on two columns


问:
PHP DOMXPath Query by node name not finding anything
I'm trying to understand the basics of DOMXPath in PHP.  I have an XML file that starts with what's below.

```<code><?xml version="1.0"?>
<ListFinancialEventsResponse xmlns="http://mws.amazonservices.com/Finances/2015-05-01">
  <ListFinancialEventsResult>
    <FinancialEvents>
      <ShipmentEventList>
        <ShipmentEvent>
</code>```

I'm trying to get the FinancialEvents tags using the below PHP with a few different xpath query attempts but neither works.

```<code>  $file = file_get_contents('file.xml');
  $dom = new DOMDocument();
  $dom->loadXML($file);

  $xpath = new DOMXPath($dom);
  $xpath->registerNamespace('m','http://mws.amazonservices.com/Finances/2015-05-01');

  $events = $xpath->query('FinancialEvents');  // Attempt 1
  $events = $xpath->query('m:FinancialEvents');// Attempt 2
</code>```

According to the docs, these should return all nodes with name 'FinancialEvents'.  I know that it works if I use the below xpath query

```<code>  $events = $xpath->query('//m:FinancialEvents');
</code>```

So my question is, why don't my first 2 queries work? Isn't the element <FinancialEvents> also a node of the same name?

Thanks

答:
Not tested but you could try:

```<code>$query='//ListFinancialEventsResult/FinancialEvents';
$events=$xp->query( $query );
if( !empty( $events ) && $events->length > 0 ){
    foreach( $events as $event ){
        echo $event->nodeValue;
    }
}
</code>```

I suspect that the first couple of queries do not return a nodelist is because you are effectively trying to find nodes FinancialEvents at root level ~ if you supplied a reference node ( which would be a DOMNode ListFinancialEventsResult )for the query then it would work.

Body:
I'm trying to understand the basics of DOMXPath in PHP.  I have an XML file that starts with what's below.

<?xml version="1.0"?>
<ListFinancialEventsResponse xmlns="http://mws.amazonservices.com/Finances/2015-05-01">
  <ListFinancialEventsResult>
    <FinancialEvents>
      <ShipmentEventList>
        <ShipmentEvent>

I'm trying to get the FinancialEvents tags using the below PHP with a few different xpath query attempts but neither works.

  $file = file_get_contents('file.xml');
  $dom = new DOMDocument();
  $dom->loadXML($file);

  $xpath = new DOMXPath($dom);
  $xpath->registerNamespace('m','http://mws.amazonservices.com/Finances/2015-05-01');

  $events = $xpath->query('FinancialEvents');  // Attempt 1
  $events = $xpath->query('m:FinancialEvents');// Attempt 2

According to the docs, these should return all nodes with name 'FinancialEvents'.  I know that it works if I use the below xpath query

  $events = $xpath->query('//m:FinancialEvents');

So my question is, why don't my first 2 queries work? Isn't the element <FinancialEvents> also a node of the same name?

Thanks

Body:
Not tested but you could try:

$query='//ListFinancialEventsResult/FinancialEvents';
$events=$xp->query( $query );
if( !empty( $events ) && $events->length > 0 ){
    foreach( $events as $event ){
        echo $event->nodeValue;
    }
}

I suspect that the first couple of queries do not return a nodelist is because you are effectively trying to find nodes FinancialEvents at root level ~ if you supplied a reference node ( which would be a DOMNode ListFinancialEventsResult )for the query then it would work.


问:
English texts lexicon comparison
Let's imagine, we can build a statistics table, how much each word is used in some English text or book. We can gather statistics for each text/book in library.
What is the simplest way to compare these statistics with each other? How can we find group/cluster of texts with very statistically similar lexicon?</p>

答:
You might consider Kullback Leibler distance.  For reference, see page 18 of Cover and Thomas:

Chapter 2, Cover and Thomas

ContentLicense: CC BY-SA 2.5

Title: English texts lexicon comparison


问:
convert the complex XML to CSV file
When I tried to Convert the below format complex XML into CSV file through some online tools it's providing multiple csv files? Is that only way to have all the below XML elements and it's attributes to be converted into multiple CSV? or Is that any way to create one csv file with all the below elements and attributes in the xml?

SAMPLE XML:

```<code><messages>
<message messageID="12345" orderNumber="1111111" model="AA" tls="22222" status="99" timestamp="2014-04-25 08:27:17Z">
    <attributes>
        <attribute name="aaaaaaaaaa" value="ff" />
        <attribute name="bbbbbbbb" value="L.f" />
        <attribute name="ccccccccc" value="333" />
        <attribute name="ddddddddd" value="n.998" />
    </attributes>
</message>
<message messageID="12345" orderNumber="1111111" model="AA" tls="22222" status="99" timestamp="2014-04-25 08:27:17Z">
    <attributes>
        <attribute name="yyyyyyy" value="j8" />
        <attribute name="jjjjjjjjjj" value="L.O" />
        <attribute name="mmmmmmm" value="33333" />
        <attribute name="nnnnnnnn" value="K.9999" />
    </attributes>
</message>
</messages>
</code>```

答:
I used this app from windows store:
https://www.microsoft.com/en-us/store/p/xml-into-csv/9p0qsrvjcsj5

It's capable to normalize whole xml into flat-table structure:

Title: convert the complex XML to CSV file

Body:
When I tried to Convert the below format complex XML into CSV file through some online tools it's providing multiple csv files? Is that only way to have all the below XML elements and it's attributes to be converted into multiple CSV? or Is that any way to create one csv file with all the below elements and attributes in the xml?

SAMPLE XML:

<messages>
<message messageID="12345" orderNumber="1111111" model="AA" tls="22222" status="99" timestamp="2014-04-25 08:27:17Z">
    <attributes>
        <attribute name="aaaaaaaaaa" value="ff" />
        <attribute name="bbbbbbbb" value="L.f" />
        <attribute name="ccccccccc" value="333" />
        <attribute name="ddddddddd" value="n.998" />
    </attributes>
</message>
<message messageID="12345" orderNumber="1111111" model="AA" tls="22222" status="99" timestamp="2014-04-25 08:27:17Z">
    <attributes>
        <attribute name="yyyyyyy" value="j8" />
        <attribute name="jjjjjjjjjj" value="L.O" />
        <attribute name="mmmmmmm" value="33333" />
        <attribute name="nnnnnnnn" value="K.9999" />
    </attributes>
</message>
</messages>


问:
Ruby on Rails v5.1 and Paperclip gem
I am working on the Rails application, using Ubuntu. Everything was fine until I have tried to add images to the website using paperclip gem and Imagemagick.

I have implemented the code as required, including models, controllers and probably views, and when I click the create/submit button all the fields in the form get accepted and updated in the database, including images. But on the website it gives the following error:

```<code>undefined method `image' for nil:NilClass
</code>```

and this is the line which gives the error:

```<code><%= image_tag @current_user.image.url(:medium) %>
</code>```

I have already tried to drop the database and to work with new migration, but the error still rises up when I try to create new user.

答:
As mentioned in the comments, @current_user is an ActiveRecord::Relation, but you need a record to access image.  Since it looks like you only have one item in the relation, you can access the first (and only) record with the first method:

```<code><%= image_tag @current_user.first.image.url(:medium) %>
</code>```

However, a better approach would be to do this in the Controller or Helper that sets @current_user in the first place.  You could simply append .first to the expression that you use to set @current_user.

One caveat, by appending .first you will always be selecting the first record in the relation. If your query returns multiple records, all of the records expect the first one will be ignored. This is not normally a problem if your query searches for something unique, like an id.

Title: Ruby on Rails v5.1 and Paperclip gem

Body:
I am working on the Rails application, using Ubuntu. Everything was fine until I have tried to add images to the website using paperclip gem and Imagemagick.

I have implemented the code as required, including models, controllers and probably views, and when I click the create/submit button all the fields in the form get accepted and updated in the database, including images. But on the website it gives the following error:

undefined method `image' for nil:NilClass

and this is the line which gives the error:

<%= image_tag @current_user.image.url(:medium) %>

I have already tried to drop the database and to work with new migration, but the error still rises up when I try to create new user.

Body:
As mentioned in the comments, @current_user is an ActiveRecord::Relation, but you need a record to access image.  Since it looks like you only have one item in the relation, you can access the first (and only) record with the first method:

<%= image_tag @current_user.first.image.url(:medium) %>

However, a better approach would be to do this in the Controller or Helper that sets @current_user in the first place.  You could simply append .first to the expression that you use to set @current_user.

One caveat, by appending .first you will always be selecting the first record in the relation. If your query returns multiple records, all of the records expect the first one will be ignored. This is not normally a problem if your query searches for something unique, like an id.


问:
Merge/concatenate select properties in javascript/typescript array
I have a function that pulls drugs into a javascript object from the server via odata and it currently returns an array of drugs in json.

How do I create a display name property on the return object that concatenates/joins certain properties so that the returned drug array has a new property called displayname that should equal to following string:

```<code> "Dosage:" + drug.Name + "-" + drug.AlternateNames + " (" + drug.Type + ") " + drug.Indication
</code>```

Code to pull from the server is below:

```<code>getDsTeamSiteDrugs = function () {

    var drugsUrl = environment.odataUrl + "Drug";

    return this.http.get(drugsUrl + '?' + queryStr, options)
    .map((drugs) => this.processDsTeamSiteDrugs(drugs))
}

processDsTeamSiteDrugs(response) {
    return <any[]>response.json()
}
</code>```

An example response array is

```<code>[{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.816Z","version":"AAAAAAAAJ6Q=","id":"48","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280864-db83-11e7-9296-cec278b6b50a","notes":"q4-6h","perWeightMax":2.00,"perWeightMin":0.25,"perWeight":0.00,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Analgesia","alternateNames":"","name":"Morphine","drugCategory":"Analgesic"},{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.843Z","version":"AAAAAAAAJ7g=","id":"72","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280e7c-db83-11e7-9296-cec278b6b50a","notes":"q4-6h","perWeightMax":0.30,"perWeightMin":0.10,"perWeight":0.00,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Analgesia","alternateNames":"","name":"Morphine","drugCategory":"Analgesic"},{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.846Z","version":"AAAAAAAAJ70=","id":"78","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280e7c-db83-11e7-9296-cec278b6b50a","notes":"use with mIdazolam or diazepam","perWeightMax":0.00,"perWeightMin":0.00,"perWeight":0.50,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Premed","alternateNames":"","name":"Morphine","drugCategory":"Anesthesia"},{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.85Z","version":"AAAAAAAAJ74=","id":"79","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280864-db83-11e7-9296-cec278b6b50a","notes":"given with 0.05mg/kg Ace IM","perWeightMax":0.00,"perWeightMin":0.00,"perWeight":0.50,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Premed","alternateNames":"","name":"Morphine","drugCategory":"Anesthesia"}]
</code>```

Expected result

"Dosage:" + drug.Name + "-" + drug.AlternateNames + " (" + drug.Type + ") " + drug.Indication
Dosage:  Morphine- (mg/ml) Anesthesia Premed

答:
After you get a Promise for your array of objects using response.json(), you can use then to make modifications to the array of objects once the response is available.

```<code>processDsTeamSiteDrugs(response) {
  return response.json().then((drugs) => {
    for (const drug of drugs) {
       drug.displayname = `Dosage: ${drug.Name}-${drug.AlternateNames}(${drug.Type}) ${drug.Indication}`;
    }
    return drugs;
  });
}
</code>```

Body:
I have a function that pulls drugs into a javascript object from the server via odata and it currently returns an array of drugs in json.

How do I create a display name property on the return object that concatenates/joins certain properties so that the returned drug array has a new property called displayname that should equal to following string:

 "Dosage:" + drug.Name + "-" + drug.AlternateNames + " (" + drug.Type + ") " + drug.Indication

Code to pull from the server is below:

getDsTeamSiteDrugs = function () {

    var drugsUrl = environment.odataUrl + "Drug";

    return this.http.get(drugsUrl + '?' + queryStr, options)
    .map((drugs) => this.processDsTeamSiteDrugs(drugs))
}

processDsTeamSiteDrugs(response) {
    return <any[]>response.json()
}

An example response array is

[{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.816Z","version":"AAAAAAAAJ6Q=","id":"48","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280864-db83-11e7-9296-cec278b6b50a","notes":"q4-6h","perWeightMax":2.00,"perWeightMin":0.25,"perWeight":0.00,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Analgesia","alternateNames":"","name":"Morphine","drugCategory":"Analgesic"},{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.843Z","version":"AAAAAAAAJ7g=","id":"72","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280e7c-db83-11e7-9296-cec278b6b50a","notes":"q4-6h","perWeightMax":0.30,"perWeightMin":0.10,"perWeight":0.00,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Analgesia","alternateNames":"","name":"Morphine","drugCategory":"Analgesic"},{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.846Z","version":"AAAAAAAAJ70=","id":"78","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280e7c-db83-11e7-9296-cec278b6b50a","notes":"use with mIdazolam or diazepam","perWeightMax":0.00,"perWeightMin":0.00,"perWeight":0.50,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Premed","alternateNames":"","name":"Morphine","drugCategory":"Anesthesia"},{"deleted":false,"updatedAt":null,"createdAt":"2017-12-09T05:34:30.85Z","version":"AAAAAAAAJ74=","id":"79","type":"mg/ml","allConcentration":"15mg/ml","concentration":"15mg/ml","animalTypeId":"af280864-db83-11e7-9296-cec278b6b50a","notes":"given with 0.05mg/kg Ace IM","perWeightMax":0.00,"perWeightMin":0.00,"perWeight":0.50,"perWeightTypeId":"c51d9efe-db83-11e7-9296-cec278b6b50a","route":"SQ,IM","indication":"Premed","alternateNames":"","name":"Morphine","drugCategory":"Anesthesia"}]

Expected result

"Dosage:" + drug.Name + "-" + drug.AlternateNames + " (" + drug.Type + ") " + drug.Indication
Dosage:  Morphine- (mg/ml) Anesthesia Premed

Body:
After you get a Promise for your array of objects using response.json(), you can use then to make modifications to the array of objects once the response is available.

processDsTeamSiteDrugs(response) {
  return response.json().then((drugs) => {
    for (const drug of drugs) {
       drug.displayname = `Dosage: ${drug.Name}-${drug.AlternateNames}(${drug.Type}) ${drug.Indication}`;
    }
    return drugs;
  });
}


问:
Spring data JpaException "Could not extract ResultSet" on insert method with native sql
i have a simple insert query in my reservation repository that i just can not make to work;
I tried running it in mysql console and did not get any errors, i don`t have any problems with other methods that use native query tag and my repositories work fine.

```<code>    @Query(value = "INSERT INTO user_reservation(movie_id, user_psid, is_activated) VALUES (?1,?2, false)", nativeQuery = true)
        void createSetMovie(int movieId, String userId);

    @Entity(name = "user_reservation")
    public class UserReservation {
        @Id
        @GeneratedValue
        private Integer id;

        @Column(name = "num_of_tickets", nullable = true)
        private int numberOfTickets;

        @Column(name = "is_activated")
        private boolean isActivated;
        @ManyToOne(optional = true)
        private Cinema cinema;
        @ManyToOne(optional = true)
        private Movie movie;
        @ManyToOne(optional = true)
        private MovieSession session;
        @ManyToOne(optional = true)
        private MessengerUser user;

        @Temporal(TemporalType.TIMESTAMP)
        private Date timestamp;

    ...
    gettters and setters
    ...
}
</code>```

Exception stack trace

```<code>org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:333) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:488) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at com.sun.proxy.$Proxy92.createSetMovie(Unknown Source) ~[na:na]
    at com.bots.crew.pp.webhook.services.UserReservationService.saveForMovie(UserReservationService.java:16) ~[classes/:na]
    at com.bots.crew.pp.webhook.observers.BuyTicketForMovieObserver.notify(BuyTicketForMovieObserver.java:38) ~[classes/:na]
    at com.bots.crew.pp.webhook.observers.BuyTicketForMovieObserver.notify(BuyTicketForMovieObserver.java:18) ~[classes/:na]
    at com.bots.crew.pp.webhook.handlers.FacebookMessagingHandlerImpl.notify(FacebookMessagingHandlerImpl.java:49) ~[classes/:na]
    at com.bots.crew.pp.webhook.handlers.FacebookMessagingHandlerImpl.execute(FacebookMessagingHandlerImpl.java:43) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.getResultSet(Loader.java:2117) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1900) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1876) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doQuery(Loader.java:919) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doList(Loader.java:2617) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doList(Loader.java:2600) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.list(Loader.java:2424) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:336) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1967) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:322) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:125) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:529) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:372) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at com.sun.proxy.$Proxy105.getSingleResult(Unknown Source) ~[na:na]
    at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:206) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:85) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:116) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:106) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:483) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    ... 24 common frames omitted
Caused by: java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:469) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1923) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) ~[tomcat-jdbc-8.5.15.jar:na]
    at com.sun.proxy.$Proxy96.executeQuery(Unknown Source) ~[na:na]
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    ... 59 common frames omitted
</code>```

Can anyone please help me solve this issue.

答: Had to add @Modifying and @Transactional annotations on the query method. Issue solved.</p>

Body:
i have a simple insert query in my reservation repository that i just can not make to work;
I tried running it in mysql console and did not get any errors, i don`t have any problems with other methods that use native query tag and my repositories work fine.

    @Query(value = "INSERT INTO user_reservation(movie_id, user_psid, is_activated) VALUES (?1,?2, false)", nativeQuery = true)
        void createSetMovie(int movieId, String userId);

    @Entity(name = "user_reservation")
    public class UserReservation {
        @Id
        @GeneratedValue
        private Integer id;

        @Column(name = "num_of_tickets", nullable = true)
        private int numberOfTickets;

        @Column(name = "is_activated")
        private boolean isActivated;
        @ManyToOne(optional = true)
        private Cinema cinema;
        @ManyToOne(optional = true)
        private Movie movie;
        @ManyToOne(optional = true)
        private MovieSession session;
        @ManyToOne(optional = true)
        private MessengerUser user;

        @Temporal(TemporalType.TIMESTAMP)
        private Date timestamp;

    ...
    gettters and setters
    ...
}

Exception stack trace

org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:333) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:244) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:488) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:133) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:57) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at com.sun.proxy.$Proxy92.createSetMovie(Unknown Source) ~[na:na]
    at com.bots.crew.pp.webhook.services.UserReservationService.saveForMovie(UserReservationService.java:16) ~[classes/:na]
    at com.bots.crew.pp.webhook.observers.BuyTicketForMovieObserver.notify(BuyTicketForMovieObserver.java:38) ~[classes/:na]
    at com.bots.crew.pp.webhook.observers.BuyTicketForMovieObserver.notify(BuyTicketForMovieObserver.java:18) ~[classes/:na]
    at com.bots.crew.pp.webhook.handlers.FacebookMessagingHandlerImpl.notify(FacebookMessagingHandlerImpl.java:49) ~[classes/:na]
    at com.bots.crew.pp.webhook.handlers.FacebookMessagingHandlerImpl.execute(FacebookMessagingHandlerImpl.java:43) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor$1.call(AsyncExecutionInterceptor.java:115) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: org.hibernate.exception.GenericJDBCException: could not extract ResultSet
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:95) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.getResultSet(Loader.java:2117) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1900) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1876) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doQuery(Loader.java:919) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doList(Loader.java:2617) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.doList(Loader.java:2600) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.Loader.list(Loader.java:2424) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:336) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1967) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:322) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:125) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
    at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:529) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:372) ~[spring-orm-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at com.sun.proxy.$Proxy105.getSingleResult(Unknown Source) ~[na:na]
    at org.springframework.data.jpa.repository.query.JpaQueryExecution$SingleEntityExecution.doExecute(JpaQueryExecution.java:206) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:85) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:116) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:106) ~[spring-data-jpa-1.11.4.RELEASE.jar:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:483) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:461) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:56) ~[spring-data-commons-1.13.4.RELEASE.jar:na]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) ~[spring-tx-4.3.9.RELEASE.jar:4.3.9.RELEASE]
    ... 24 common frames omitted
Caused by: java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:469) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1923) ~[mysql-connector-java-5.1.42.jar:5.1.42]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.apache.tomcat.jdbc.pool.StatementFacade$StatementProxy.invoke(StatementFacade.java:114) ~[tomcat-jdbc-8.5.15.jar:na]
    at com.sun.proxy.$Proxy96.executeQuery(Unknown Source) ~[na:na]
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
    ... 59 common frames omitted

Can anyone please help me solve this issue.


问:
How to debug in Android Studio using adb over WiFi
I'm able to connect to my phone using adb connect, and I can adb shell also.

But when I go to Run->Device Chooser, there are no devices there.

What should I do to connect my (connected) adb Android Studio?

When I plug it in through USB, it shows up on the list

答:
If you are using a rooted phone then try this application WiFi ADB.

Probably this is the most simplest way to debug on wifi.

I am using this application from many days and it works flawlessly.


问:
Inserting byte file inside html  tag
I'm using Angular 2 to retrieve image from backend. My response looks like that

```<code>{ AcceptRanges: 'bytes',
LastModified: 'Sat, 09 Dec 2017 17:06:46 GMT',
ContentLength: '462882',
ETag: '"c0ff5b060c2da69deff97065d43e3645"',
ContentType: 'application/octet-stream',
Metadata: {},
Body: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 00 64 00 00 ff ec 00 11 4475 63 6b 79 00 01 00 04 00 00 00 3c 00 00 ff ee 00 0e 41 64 6f 62 65 00 64 ... > }
</code>```

Is there any chance I can insert that thing directly inside html img tag, or should I start off by converting it to say base64? Thank you in advance.

答:
a solution is to use Base64 Image source, that should return encoded base64 from backend. forExample:</p>

```<code>img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP//ywAAAAAAQABAAACAUwAOw==";
</code>```

Title: Inserting byte file inside html <img> tag

Body:
I'm using Angular 2 to retrieve image from backend. My response looks like that

{ AcceptRanges: 'bytes',
LastModified: 'Sat, 09 Dec 2017 17:06:46 GMT',
ContentLength: '462882',
ETag: '"c0ff5b060c2da69deff97065d43e3645"',
ContentType: 'application/octet-stream',
Metadata: {},
Body: <Buffer ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 00 64 00 00 ff ec 00 11 4475 63 6b 79 00 01 00 04 00 00 00 3c 00 00 ff ee 00 0e 41 64 6f 62 65 00 64 ... > }

Is there any chance I can insert that thing directly inside html img tag, or should I start off by converting it to say base64? Thank you in advance.

Body:
a solution is to use Base64 Image source, that should return encoded base64 from backend. forExample:

img.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP//ywAAAAAAQABAAACAUwAOw==";


问:
Custom tabs for unhandled applinks
I have implemented applinks to handle all the url's from my domain as follows

```<code>    <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="www.example.com"
                android:scheme="http" />
     </intent-filter>
</code>```

but i would like to open some links from the same domain in customtabs.I am implementing this logic to invoke those links in customtabs

```<code>    CustomTabsServiceConnection connection = new CustomTabsServiceConnection() {
        @Override
        public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient client) {
            client.warmup(0L);
            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
            builder.setInstantAppsEnabled(false);
            builder.setToolbarColor(context.getResources().getColor(R.color.pure_white));
            builder.setSecondaryToolbarColor(context.getResources().getColor(R.color.pure_white));
            builder.setShowTitle(true);
            CustomTabsIntent customTabsIntent = builder.build();
            customTabsIntent.launchUrl(context,Uri.parse("http://www.example.com/unhandled"));
        }
        @Override
        public void onServiceDisconnected(ComponentName name) {}
    };
    CustomTabsClient.bindCustomTabsService(context, "com.android.chrome", connection);
</code>```

but those links were captured by my applink intent and it goes on in a loop.What am i missing? Any ideas or suggestions would be useful.

答:
Setting the package on the Intent that launches the CustomTabs should force it to open Chrome.

```<code>CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage("com.android.chrome");
customTabsIntent.launchUrl(
    context,Uri.parse("http://www.example.com/unhandled"));
</code>```

Also, since Chrome is not the only browser that supports Custom Tabs, I'd recommend following the best practices, and supporting other browsers as well.

Title: Custom tabs for unhandled applinks

Body:
I have implemented applinks to handle all the url's from my domain as follows

    <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="www.example.com"
                android:scheme="http" />
     </intent-filter>

but i would like to open some links from the same domain in customtabs.I am implementing this logic to invoke those links in customtabs

    CustomTabsServiceConnection connection = new CustomTabsServiceConnection() {
        @Override
        public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient client) {
            client.warmup(0L);
            CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
            builder.setInstantAppsEnabled(false);
            builder.setToolbarColor(context.getResources().getColor(R.color.pure_white));
            builder.setSecondaryToolbarColor(context.getResources().getColor(R.color.pure_white));
            builder.setShowTitle(true);
            CustomTabsIntent customTabsIntent = builder.build();
            customTabsIntent.launchUrl(context,Uri.parse("http://www.example.com/unhandled"));
        }
        @Override
        public void onServiceDisconnected(ComponentName name) {}
    };
    CustomTabsClient.bindCustomTabsService(context, "com.android.chrome", connection);

but those links were captured by my applink intent and it goes on in a loop.What am i missing? Any ideas or suggestions would be useful.

Body:
Setting the package on the Intent that launches the CustomTabs should force it to open Chrome.

CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.intent.setPackage("com.android.chrome");
customTabsIntent.launchUrl(
    context,Uri.parse("http://www.example.com/unhandled"));

Also, since Chrome is not the only browser that supports Custom Tabs, I'd recommend following the best practices, and supporting other browsers as well.


问:
Automated testing of AEM Workflows
Is there a way I can automate testing of Adobe AEM workflows?

I've looked at Hobbes.js but there's no mention of workflows as far as I can see. This would be ideal if it handled workflows across multiple users.

I think this might be too challenging for Cucumber and arduous to get working reliably. I've also considered Prosper but that's essentially mock framework.

答:
Testing workflows can be tricky but it's possible. If you think about it, it's not much different from testing any other web application. You just need a way to control the browser, switch between accounts and manage potentially complex test scenarios in a comprehensible way.

Another key requirement that in my opinion is the main problem with Hobbes is that the test code needs to be possible to execute easily from a command line and generate useful reports for later consumption. Without this, it's difficult to integrate such tests into any automated pipeline on a CI server.

My current project team has had some success testing customized approval and replication workflows. The tests took a lot of time to write compared to the time we spent actually cusomizing the workflows but the tests are stable.

Our approach relies on browser-based testing of the Author instance using a combination of Selenium Web Driver Java (for browser control), Google Guice (for managing complex graphs of page objects and various utility functions) and JUnit/Cucumber for the control of test scenarios.

One of the key challenges is that the WYSIWYG AEM authoring interface tends not to behave very reliably in terms of how quickly it loads. There's a lot of dynamic parts, some of which are based on ajax calls.

The task is especially difficult if you use Classic UI with its ExtJS front-end and many, many iframes. With Touch UI, targeting the right elements of the interface is a lot easier in my opinion.

That said, you'll have to put quite a lot of effort into figuring out the quirks of these interfaces before you're able to write test code efficiently.

The company I work for noticed that and based on our experience with numerous AEM projects, we put together a framework that takes one's mind off most of the boilerplate code. It provides interfaces for interacting with key elements of the AEM UI out of the box.

We open-sourced it under the Apache 2.0 License. It's called Bobcat. Feel free to check out the project's Github page and have a look at a simple example project.

Bobcat has also been adopted outside of Cognifide. This blog by liatrio contains a nice summary of the features they found especially useful.

Title: Automated testing of AEM Workflows


问:
Converting JSON string to UIImage
I'm looking for an example of how I can display a specific UIImage (held in Asset catalog) based on what string is passed from the JSON response.

E.g. if the database_field has "Balloons" selected, it won't display the word "Balloons" but convert it to display the image "Balloons".
I have tried using switch and case to change the String to an image but get all sorts of compilation errors.

EDIT

What I was looking for, and what I couldn't get working (because I'm new to switch...!) was the following code:

```<code>        if let imgType = bug.bugType {

        var imgTypeImageName = ""
        switch imgType {
        case "Ballons":
            imgTypeImageName = "Balloons"
            break
        case "Apple":
            imgTypeImageName = "Apple"
            break
        default:
            imgTypeImageName = "default"
            break
        }

        imgIconImage.image = UIImage(named: imgTypeImageName)
    }
</code>```

Hope this helps someone!

答:
Just use the initializer for UIImage that accepts a string for the image name.  Here is an example playground.  You need to drag in test.jpg into the Resources folder on the left hand side for this playground to run correctly.</p>

```<code>import PlaygroundSupport
import UIKit

let jsonData = """
{
"imageName" : "test.jpg"
}
""".data(using: .utf8)!

struct CustomStruct: Codable {
    let imageName: String
    var image: UIImage? {
        return UIImage(named: imageName)
    }
}

let custom = try! JSONDecoder().decode(CustomStruct.self, from: jsonData)
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
imageView.image = custom.image
PlaygroundPage.current.liveView = imageView
</code>```

ContentLicense: CC BY-SA 4.0

Title: Converting JSON string to UIImage

Body:
I'm looking for an example of how I can display a specific UIImage (held in Asset catalog) based on what string is passed from the JSON response.

E.g. if the database_field has "Balloons" selected, it won't display the word "Balloons" but convert it to display the image "Balloons".
I have tried using switch and case to change the String to an image but get all sorts of compilation errors.

EDIT

What I was looking for, and what I couldn't get working (because I'm new to switch...!) was the following code:

        if let imgType = bug.bugType {

        var imgTypeImageName = ""
        switch imgType {
        case "Ballons":
            imgTypeImageName = "Balloons"
            break
        case "Apple":
            imgTypeImageName = "Apple"
            break
        default:
            imgTypeImageName = "default"
            break
        }

        imgIconImage.image = UIImage(named: imgTypeImageName)
    }

Hope this helps someone!

Body:
Just use the initializer for UIImage that accepts a string for the image name.  Here is an example playground.  You need to drag in test.jpg into the Resources folder on the left hand side for this playground to run correctly.

import PlaygroundSupport
import UIKit

let jsonData = """
{
"imageName" : "test.jpg"
}
""".data(using: .utf8)!

struct CustomStruct: Codable {
    let imageName: String
    var image: UIImage? {
        return UIImage(named: imageName)
    }
}

let custom = try! JSONDecoder().decode(CustomStruct.self, from: jsonData)
let imageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
imageView.image = custom.image
PlaygroundPage.current.liveView = imageView


问:
Error: Archive for required library cannot be read or is not a valid ZIP file.
I am having trouble setting up the build path of my java project. I am currently in a Co-Op IT position so I am somewhat new to all this. My background is mostly in C++ and I am learning java on the fly. I am also somewhat new to Eclipse (Kepler service release 1).

I am working on a bug on an existing program and need to get the program to build so I can work on it. When I add all of the external .jar files that I know for a fact are the right ones, I am getting this error on two of them :

"Archive for required library: '(location of file)' cannot be read or is not a valid ZIP file"

Two of the other full time guys on my team have gotten the program to run with those exact same .jar files, one running Eclipse Indigo and the other running the same Kepler version as myself. I also was able to open the two .jar files manually and everything appears to be there. After every trial trying to fix this, I have refreshed, cleaned and restarted eclipse. The two other full time guys said they have never seen this error. I would like to get some insight on this from anyone who has any similar experiences so that I don't have to use up much more of their time.

答:
In my case ..worked after removing this from spirngrest-servlet.xml file.

```<code>    <prop key="net.sf.ehcache.configurationResourceName">/Sysehcache.xml</prop>
</code>```

I think it had to do with default location of maven repository of jar files.
Been at it for 3 days. finally solved it.Hope it helps anyone.Just look for similar think in your spirngrest-servlet.xml file. Good luck.

Body:
In my case ..worked after removing this from spirngrest-servlet.xml file.

    <prop key="net.sf.ehcache.configurationResourceName">/Sysehcache.xml</prop>

I think it had to do with default location of maven repository of jar files.
Been at it for 3 days. finally solved it.Hope it helps anyone.Just look for similar think in your spirngrest-servlet.xml file. Good luck.


问:
Convolutional Neural Network with Logarithmic and Exponential activation functions
I am trying to implement a very specific convolutional neural network using Keras.

The key difference is that I have to use non-usual activation functions: log and exp.
The basic structure of the ConvNet is as follows:

Input => Conv2D => Activation Log => Avg Pooling => Activation Exp => ...

The problem is: as the weights get too small, the log activation rapidly reaches -inf.

The reason why I need to use log and exp is because for certain layers I want to simulate what would be a *product pooling *, that is the product of a smaller window (filter) of the current layer.
If I apply log(a) and log(b), I can do a normal average pooling ~ log(a)+log(b) followed by an exp activation which corresponds to that product I want: a * b = exp( log(a)+log(b) ).

To get rid of the -inf I have tried to train the network with SGD and lower learning rate, so I could get larger weights, but it didn't work.

Please, do you have any idea on how could I avoid the -inf due to very small weights, or a smarter way of getting the product pooling without needing a log activation function?

Thank you.

答:
The fact that your activation output is rapidly reaching -inf tells me that the output of your convolution layer is quite small! I cannot provide you with a definite answer to how to avoid the -inf, for it depends on the structure of your network, the range of values of your input, and the task the network is trained to do.

However, I'd suggest two possible solutions:

You may need to reconsider your weight initialization technique. Many practical CNNs initialize from a Gaussian distribution with zero mean and relatively small variances, ~ 1x10^-3, and that will be an issue in you network because majority of weights are very small and will drive the convolution output below one.

Consider lower bounding your activation output, something like a max{..} function.


问:
Is it possible to get a list of keywords in Python?
I'd like to get a list of all of Pythons keywords as strings. It would also be rather nifty if I could do a similar thing for built in functions.

Something like this :

```<code>import syntax
print syntax.keywords
# prints ['print', 'if', 'for', etc...]
</code>```

答:
```<code>>>> help('keywords')

Here is a list of the Python keywords.  Enter any keyword to get more help.

False               def                 if                  raise
None                del                 import              return
True                elif                in                  try
and                 else                is                  while
as                  except              lambda              with
assert              finally             nonlocal            yield
break               for                 not
class               from                or
continue            global              pass
</code>```

Body:
I'd like to get a list of all of Pythons keywords as strings. It would also be rather nifty if I could do a similar thing for built in functions.

Something like this :

import syntax
print syntax.keywords
# prints ['print', 'if', 'for', etc...]


问:
How to get unique values excluding values from 1 of 2 tables
I need to get unique values from 2 tables, but exclude the values from the second table. I mean, I need all the values from the first table that are not in the second table and are greater than 9. The tables look like:

```
Table Gr:           Table Ak:
Idgr | TextGr       Idak | Grid | TextAk
1    | Aa           1    | 11   | R
11   | Bb           2    | 14   | P
12   | Cc           3    | 16   | P
13   | Dd           4    | 13   | P
14   | Ee
15   | Ff
16   | Gg
17   | Hh
18   | Ii
```

Grid on table Ak is the same ID from Idgr on table Gr.
I need to get result like this:

```
Results:
Idgr | TextGr
12   | Cc
15   | Ff
17   | Hh
18   | Ii
```

I tried with LEFT OUTER JOIN, but I get almost all values from table Gr. Check out SQLfiddle demo

答:
You want to test for equality in the on and then use a where to get the ones that don't match.  So, I think you want:

```<code>select Idgr, TextGr
from Gr left outer join
     Ak
     on gr.idgr = ak.gid
where gr.idgr > 9 and ak.Idak is null;
</code>```

Here is the SQL Fiddle.

Body:
I need to get unique values from 2 tables, but exclude the values from the second table. I mean, I need all the values from the first table that are not in the second table and are greater than 9. The tables look like:

Table Gr:           Table Ak:
Idgr | TextGr       Idak | Grid | TextAk
1    | Aa           1    | 11   | R
11   | Bb           2    | 14   | P
12   | Cc           3    | 16   | P
13   | Dd           4    | 13   | P
14   | Ee
15   | Ff
16   | Gg
17   | Hh
18   | Ii

Grid on table Ak is the same ID from Idgr on table Gr.
I need to get result like this:

Results:
Idgr | TextGr
12   | Cc
15   | Ff
17   | Hh
18   | Ii

I tried with LEFT OUTER JOIN, but I get almost all values from table Gr. Check out SQLfiddle demo

Body:
You want to test for equality in the on and then use a where to get the ones that don't match.  So, I think you want:

select Idgr, TextGr
from Gr left outer join
     Ak
     on gr.idgr = ak.gid
where gr.idgr > 9 and ak.Idak is null;

Here is the SQL Fiddle.


问:
React Native Navigation installation issue with React Native v0.51
I am having problem with the installation of the React Native Navigation with React Native v0.51. I saw that there are changes made to the index.ios and index.android file in favor of only one index.js file. I have made changes accordingly in AppDelegate.m but it still does not work.

AppDelegate.m

App boot up stuck in 4/478

答:
Mine is working fine with the same changes that you've made in your AppDelegate.m file like yours. But, I am still unable to get android running.

While changing my AppDelegate.m file, xcode was unable to find the RCTBundleURLProvider.h so I had to re-link React under Product > Schema > Manage Schema

For android: Adding the following method inside MainApplication class of MainApplication.java worked for me.

```<code>@Override
public String getJSMainModuleName() {
    return "index";
}
</code>```

Body:
Mine is working fine with the same changes that you've made in your AppDelegate.m file like yours. But, I am still unable to get android running.

While changing my AppDelegate.m file, xcode was unable to find the RCTBundleURLProvider.h so I had to re-link React under Product > Schema > Manage Schema

For android: Adding the following method inside MainApplication class of MainApplication.java worked for me.

@Override
public String getJSMainModuleName() {
    return "index";
}