小编vli*_*o20的帖子

MySQL LAST_INSERT_ID() - 它是如何工作的

我有这个问题:我有一个存储过程,它将行插入到具有自动增量列a的表A,然后向表B插入一行,其中有一个外键b到列Aa我LAST_INSERT_ID用来获取列的值为新插行.但是lat说有两个并行调用这个存储过程,我怎样才能确保(或者数据库本身确定)列b没有任何错误的分配.

在文档中找不到这个

mysql sql stored-procedures

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

Polymer-AngularJS双向数据绑定

我有一些用Polymer创建的自定义元素.我们称之为x-input,它看起来像这样:

<polymer-element name="x-input" attributes="name">
    <template>
        <input type="text" value={{name}}> <span>{{name}}</span>
        <br />
        <input type="range" value={{age}} > <span>{{age}}</span>
    </template>
 </polymer-element>
Run Code Online (Sandbox Code Playgroud)

我有这个HTML我使用Angular:

<html ng-app="testApp">
    <body ng-controller="AppCtrl">
        <input id="outer_input" type="text" ng-model="kids[0].name" value={{kids[0].name}} /> <br />
        <span>name: {{kids[0].name}} age: {{kids[0].age}}</span><br />
        <x-input ng-repeat="kid in kids" name={{kid.name}} age={{kid.age}}>
        </x-input>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是JS:

var testApp = angular.module('testApp', []);

testApp.controller('AppCtrl', function ($scope, $http)
{
    $scope.kids = [{"name": "Din", "age": 11}, {"name": "Dina", "age": 17}];
}
Run Code Online (Sandbox Code Playgroud)

问题在于双向数据绑定.当我更改#outer_input输入值时,x输入内部值(名称和年龄)会发生变化.

但是当我更改自定义元素输入时,只更改了内部绑定变量.

如何在聚合物元素中更改绑定变量的值,它将更改模型和所有外部绑定的UI和数据(双向绑定)?

谢谢

javascript element angularjs shadow-dom polymer

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

忽略了标准中的Hibernate提取

我有一些类User与LoginSession类有一对多的关系(我的User类中有一个LoginSessions集合).

@Entity(name="T_User")
public class User() 
{
   ....
     @OneToMany(fetch=FetchType.LAZY, mappedBy="user", cascade=CascadeType.ALL)
     @Fetch(FetchMode.SELECT)
     @JsonIgnore
     private Set<LoginSession> userLoginSession;
   ....
 }
Run Code Online (Sandbox Code Playgroud)

这是LoginSession类:

@Entity(name="T_LoginSession")
public class LoginSession extends BasicDTO
{

    @ManyToOne
    @JoinColumn(name="userId")  
    protected User user;
    ...
Run Code Online (Sandbox Code Playgroud)

我有这个标准:

Criteria crit = session.createCriteria(User.class);
crit.setFetchMode("loginSession", FetchMode.JOIN);
crit.createAlias("userLoginSession", "session");
crit.add(Restrictions.eq("session.token", sessionToken));
crit.setMaxResults(1);
crit.setFirstResult(0);
crit.setFetchSize(1);
Run Code Online (Sandbox Code Playgroud)

问题是提取始终是懒惰的.如何让它成为Eager(通过标准而不是通过属性注释)?

注意:
如果我在@Fetch注释private Set<LoginSession> userLoginSession中设置的响应提取之上添加注释(我不会按标准自定义setFetchMode).

字段的名称(方法的第一个参数setFetchMode)是否正确?

问题: 这个错误与我的问题有关吗?

java hibernate fetching-strategy

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

如何在php中发送包含html和css的电子邮件

当我通过PHP邮件functon发送电子邮件时(我把这个html代码放在一行并将其添加到邮件中),让我们说出我要发送的内容:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <style type="text/css">
        .box h3{
                text-align:right;
                position:relative;
                direction: rtl;
        }
        .box {
                width:70%;
                top:80px;
                height:200px;
                background: whitesmoke;
                margin:40px auto;
                text-align:right;
                direction: rtl;
        }
        /*==================================================
         * Effect 2
         * ===============================================*/
        .effect2
        {
                position: relative;
        }
        .effect2:before, .effect2:after
        {
                z-index: -1;
                position: absolute;
                content: "";
                bottom: 15px;
                left: 10px;
                width: 50%;
                top: 80%;
                max-width:300px;
                background: #777;
                -webkit-box-shadow: 0 15px 10px #777;
                -moz-box-shadow: 0 15px 10px #777;
                box-shadow: …
Run Code Online (Sandbox Code Playgroud)

php email html-email

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

Android应用程序崩溃,无法理解logcat找到原因

我在主要活动中有这个代码:

package flash.light.pro;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.graphics.Color;
import android.hardware.Camera.Parameters;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.view.View.OnLongClickListener;


public class MainActivity extends Activity {
    private boolean isBlack = false;
    private boolean isLedOn = false;
    private boolean supportsCamera = true;
    private Camera camera;
    final Parameters p = camera.getParameters();
    protected void onStop() {
        super.onStop();

        if (camera != null) {
            camera.release();
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        final Button screen …
Run Code Online (Sandbox Code Playgroud)

android logcat android-camera

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

从扩展View类的调用中显示FragmmentDialog

我有一个被调用的活动,MainPage它会延伸SherlockFragmentActivity.此活动有标签,每个标签显示不同的片段.其中一个片段显示一个SaleRow视图,该视图是一个自定义视图(扩展RelativeLayout该类的类).我也有SaleDialog课程延伸DialogFragment.我想要做的是从SaleRow视图类中显示SaleDialog .我试着使用这段代码:

public class SaleRow extends RelativeLayout 
{   
    public SaleRow(Context context) 
    {
        super(context);

        ...

        this.setOnClickListener(new OnClickListener() 
        {
            @Override
            public void onClick(View view) 
            {
            FragmentManager fm = getFragmentManager(); //compilation error here for getFragmentManager The method getFragmentManager() is undefined for the type new View.OnClickListener()
                SaleDialog testDialog = new SaleDialog();
                testDialog.setRetainInstance(true);
                testDialog.show(fm, "fragment_name");
            }

        });
Run Code Online (Sandbox Code Playgroud)

我已经找到了解决方案但找不到相关的东西.

Thaks

android fragment android-dialogfragment

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

希伯来语没有显示 - Android

我创建了2个字符串文件,其中一个是默认的res/values/strings.xml,另一个是在res/values-he/strings.xml.我正在打开我的应用程序,而os配置为希伯来语,但我仍然看到默认字符串的值是英文的.有什么事要做吗?

注意:在eclipse图形布局编辑器中,我可以选择希伯来语并看到它工作正常.

这是我的一些默认strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyApp</string>
<string name="title_activity_splash">MyApp</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="title_activity_login">Login</string>
<string name="email">Email</string>
<string name="password">Password</string>
<string name="forgot_password">Forgot password?</string>
<string name="sign_up">Sign up</string>
<string name="login">Login</string> 
.
.
.
Run Code Online (Sandbox Code Playgroud)

这里是所有(现在)我的希伯来strings.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="action_settings">??????</string>
    <string name="hello_world">???? ????</string>
    <string name="email">????</string>
    <string name="password">?????</string>
    <string name="forgot_password">???? ?????</string>
    <string name="sign_up">?????</string>
    <string name="login">???????</string>


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

在日食中:

在此输入图像描述

在这里它在设备上(希伯来语设备os):

在此输入图像描述

string android

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

文本对齐不起作用(css)

我有以下html:

        <div class="chat-scroll height-full">
            <div class="width-full" style="text-align: left">
                <div class="bubble-left"></div>
            </div>
            <div class="width-full">
                <div class="bubble-right" style="text-align: right"></div>
            </div>
        </div>
Run Code Online (Sandbox Code Playgroud)

这是css:

.height-full {
    height: 100%;
}

.width-full {
    width: 100%;
}


  .bubble {
    position: relative;
    max-width: 90%;
    min-height: 30px;
    padding: 5px;
    background: -webkit-linear-gradient(90deg, #3B4FCC 5%, #2196F3 100%);
    background: -moz-linear-gradient(90deg, #3B4FCC 5%, #2196F3 100%);
    background: -ms-linear-gradient(90deg, #3B4FCC 5%, #2196F3 100%);
    background: linear-gradient(180deg, #2196F3 5%, #3B4FCC 100%);
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2196F3', endColorstr='#3B4FCC');
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    margin: 10px 5px;
  }

  .bubble-left {
    @extend …
Run Code Online (Sandbox Code Playgroud)

html css

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

Nginx 缺少尾部斜杠返回 301

我有以下配置:

server {
  listen       80;
  server_name  localhost;

  location  /app {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    try_files $uri $uri/ /app/index.html?$args;
  }

  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
    root   /usr/share/nginx/html;
  }
}
Run Code Online (Sandbox Code Playgroud)

当http://localhost:8000/app/按预期导航到所有工作但删除尾部斜杠 ( http://localhost:8000/app) 时,nginx 返回 301 状态响应,我被重定向到http://localhost/app.

我怎样才能让 nginx 同时使用http://localhost:8000/app/和http://localhost:8000/app(带和不带斜杠)。

reverse-proxy nginx

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

TypeScript 装饰器中的异步调用

提前对漫长的探索表示歉意。我试图尽可能清楚地说明我面临的问题。

我创建了一个装饰器 utils 库,在使用其中一个装饰器时遇到了奇怪的行为(https://github.com/vlio20/utils-decorators/blob/master/src/after/after.ts)。

装饰器被命名为“after”,它应该在执行装饰方法后执行不同的函数。但事情是这样的,如果函数返回一个 Promise,装饰器应该等待它被解析,然后才调用 after func。

这是相关代码:

        if (resolvedConfig.wait) {
          const response = await originalMethod.apply(this, args);
          afterFunc({
            args,
            response
          });
        } else {
          const response = originalMethod.apply(this, args);
          afterFunc({
            args,
            response
          });
        }
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我为装饰器提供了一个标志,以指示装饰方法是一个异步函数,并且它返回一个 Promise。我很乐意通过以下代码来阅读此标志:

        const response = await originalMethod.apply(this, args);
          afterFunc({
            args,
            response
          });
Run Code Online (Sandbox Code Playgroud)

基本上,我希望始终放在await原始方法的执行之前,因为根据我的理解,在同步方法的情况下,等待不会执行任何操作。

问题是,当我按照上面的建议更改代码时,以下单元测试失败:

  it('should verify after method invocation when method is provided', () => {
    let counter = 0;

    const afterFunc = jest.fn(() => {
      expect(counter).toBe(1);
    });

    class …
Run Code Online (Sandbox Code Playgroud)

javascript unit-testing decorator typescript jestjs

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