问题列表 - 第49912页

Spring-JPA-Hibernate写入数据库失败(由于没有正在进行的事务而延迟身份插入)

我使用Spring 3.0.5.RELEASE和Hibernate 3.6.1.Final.从MySql DB读取是可以的,但是当我尝试写入它时,我在日志中得到了这个:

22 mars 2011 22:37:34,625 DEBUG InjectionMetadata: Processing injected method of bean 'thoughtDao': PersistenceElement for protected javax.persistence.EntityManager com.prosveta.backend.daoimpl.GenericDaoImpl.entityManager
22 mars 2011 22:37:34,625 DEBUG DefaultListableBeanFactory: Returning cached instance of singleton bean 'entityManagerFactory'
22 mars 2011 22:37:34,625 DEBUG DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
22 mars 2011 22:37:34,625 DEBUG DefaultListableBeanFactory: Creating instance of bean 'org.springframework.transaction.config.internalTransactionAdvisor'
22 mars 2011 22:37:34,640 DEBUG DefaultListableBeanFactory: Eagerly caching bean 'org.springframework.transaction.config.internalTransactionAdvisor' to allow for resolving potential circular references
22 mars 2011 22:37:34,656 DEBUG …
Run Code Online (Sandbox Code Playgroud)

mysql spring hibernate jpa-2.0

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

这个编程功能的名称是什么?

在一些动态语言中,我看到过这种语法:

myValue = if (this.IsValidObject)
{
    UpdateGraph();
    UpdateCount();
    this.Name;
}
else
{
    Debug.Log (Exceptions.UninitializedObject);
    3;
}
Run Code Online (Sandbox Code Playgroud)

基本上能够返回分支中的最后一个语句作为变量的返回值,不一定仅用于方法返回,但它们也可以实现.

这个功能的名称是什么?

这也可以用静态类型语言如C#实现吗?我知道C#有三元运算符,但我的意思是使用if语句,如上所示切换语句.

static programming-languages functional-programming dynamic

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

关于设置something.prototype .__ proto__的困惑

在Node.js的Express模块​​的代码中,我遇到了这一行,为服务器设置了继承:

Server.prototype.__proto__ = connect.HTTPServer.prototype;
Run Code Online (Sandbox Code Playgroud)

我不知道这是什么一样-在MDC文档(https://developer.mozilla.org/en/JavaScript/Guide/Inheritance_Revisited#prototype_and_ )好像说我可能只是这样做:

Server.prototype = connect.HTTPServer.prototype;
Run Code Online (Sandbox Code Playgroud)

的确,我做了这个测试:

var parent = function(){}
parent.prototype = {
    test: function(){console.log('test')};
}

var child1 = function(){};
child1.prototype = parent.prototype;
var instance1 = new child1();
instance1.test();     // 'test'

var child2 = function(){};
child2.prototype.__proto__ = parent.prototype;
var instance2 = new child2();
instance2.test();     // 'test'
Run Code Online (Sandbox Code Playgroud)

看起来一样吗?所以,是的,我想知道设置object.prototype .__ proto是为了什么.谢谢!

javascript node.js

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

php <5.3的替代finfo()

<?php 
$finfo = new finfo();
$fileinfo = $finfo->file($_FILES["fileToUpload"]["tmp_name"], FILEINFO_MIME);

switch($fileinfo) {
    case "image/gif":
    case "image/jpeg":
    case "image/png":
       move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
    "upload/" . $_FILES["fileToUpload"]["name"]);
    echo "Your file has successfully been uploaded, and is awaiting moderator approval for points." . "<html><br><a href='uploadfile.php'>Upload more.</a>";
    break;
     default:
     echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb";

        break;
        }


?>
Run Code Online (Sandbox Code Playgroud)

它最近引起了我的注意,这里没有任何错误,它只是不起作用,因为我的服务器PHP只有5.2 lemme知道如果你们能找到一种方法使它使用MIME工作

php

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

foreach循环中的PERL范围

我有一个perl范围问题.

use strict;
use warnings;

our @cycles = (0,1,2,3,4);

foreach my $cycle (@cycles){
    my $nextcycle = 0;
    foreach $nextcycle (@cycles){
        if ($cycle+1 == $nextcycle){
            print "found cycle+1, $nextcycle\n";
            last;
        }
    }
    print "current=$cycle, nextcycle=$nextcycle\n";
}
Run Code Online (Sandbox Code Playgroud)

我得到的输出:

发现周期+ 1,1

current = 0,nextcycle = 0

发现周期+ 1,2

current = 1,nextcycle = 0

发现周期+ 1,3

current = 2,nextcycle = 0

发现周期+ 1,4

current = 3,nextcycle = 0

current = 4,nextcycle = 0

我期待这个:

发现周期+ 1,1

current = 0,nextcycle = 1

发现周期+ 1,2

current …

perl

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

Ant:[xslt] java.lang.ClassNotFoundException:org.apache.tools.ant.taskdefs.optional.TraXLiaison

我有一个Ant版本在Windows上可以正常工作,但是当我将它带到Linux时似乎已经崩溃了.问题在于:

[xslt] java.lang.ClassNotFoundException:org.apache.tools.ant.taskdefs.optional.TraXLiaison

我已经尝试过以下方法:

  1. xalan.jar,xercesImpl.jarxml-apis.jar$ANT_HOME/lib目录中.
  2. 将它们放入构建文件中的类路径中
  3. 安装ant的可选类.

我正在使用EC2 Linux实例(基本的64位Amazon Linux AMI 2011.02.1 Beta(AMI Id:ami-8e1fece7)Amazon Linux AMI Base 2011.02.1,EBS启动,使用Amazon EC2 AMI工具的64位架构.)

令人沮丧的是,我让它工作,然后当我把所有东西打包并移动到另一台机器时,两台机器停止工作.:(

java ant xslt

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

在几个线程上运行Parallel.Foreach的性能

我有3个主要的处理线程,每个线程都通过Parallel.Foreach对ConcurrentDictionaries的值执行操作.词典的大小从1,000个元素到250,000个元素不等

TaskFactory factory = new TaskFactory();
Task t1 = factory.StartNew(() =>
{
        Parallel.ForEach(dict1.Values, item => ProcessItem(item));
});

Task t2 = factory.StartNew(() =>
{                                
        Parallel.ForEach(dict2.Values, item => ProcessItem(item));
});

Task t3 = factory.StartNew(() =>
{                           
        Parallel.ForEach(dict3.Values, item => ProcessItem(item));
});
t1.Wait();
t2.Wait();
t3.Wait();
Run Code Online (Sandbox Code Playgroud)

我比较了这个构造的性能(总执行时间)和刚刚在主线程中运行Parallel.Foreach并且性能提高了很多(执行时间减少了大约5倍)

我的问题是:

  1. 上面的方法有问题吗?如果是,那么改进的内容和方式如何?
  2. 执行时间不同的原因是什么?
  3. 调试/分析这种情况的好方法是什么?

编辑:进一步澄清情况:我在WCF服务上模拟客户端调用,每个调用都来自一个单独的线程(任务的原因).我还尝试使用ThreadPool.QueueUserWorkItem而不是Task,没有性能提升.字典中的对象具有20到200个属性(只是小数和字符串),并且没有I/O活动

我通过在BlockingCollection中排队处理请求并在那时处理它们来解决了这个问题

.net c# parallel-processing performance

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

为什么这个grep过滤器很慢?

我想获得BSD词典单词列表中每个单词的前两个字母,不包括那些只以一个字母开头的单词.

没有单字母排除,它运行速度非常快:

time cat /usr/share/dict/web2 | cut -c 1-2 | tr '[a-z]' '[A-Z]' | uniq -c > /dev/null

real    0m0.227s
user    0m0.375s
sys 0m0.021s
Run Code Online (Sandbox Code Playgroud)

..然而,在' ' 上gre is很痛苦:

time cat /usr/share/dict/web2 | cut -c 1-2 | grep '..' | tr '[a-z]' '[A-Z]' | uniq -c > /dev/null

real    1m16.319s
user    1m0.694s
sys 0m10.225s
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

regex unix command-line grep

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

将struct __CFString*转换为CFStringRef

如何将struct __CFString*转换为CFStringRef?谢谢.

core-foundation

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

如何创建CSV以使数字在电子表格中显示为字符串?

我正在尝试构建一个从数据库中提取一些数据的应用程序,然后使用一些数据创建一个由Excel加载的CSV文件.代码:

foreach (xOFDocInfo cm in docs)
{
    string s = bi.Agency
        + "," + cm.BatNbr.Trim()
        + "," + cm.RefNbr
        + "," + cm.DocType
        + "," + cm.OrigDocAmt.ToString()
        + "," + cm.CreateDate.ToShortDateString();

    writer.WriteLine(s);

}
Run Code Online (Sandbox Code Playgroud)

"cm.BatNbr"是一个6个字符的零填充数字,例如"001234".我希望Excel将该列格式化为文本,这样我就不会在前面丢失零.我尝试了一些技巧,比如用单引号(撇号)为数字添加前缀,但我得到的只是一个撇号前缀.如果我将单元格设置为文本格式然后删除撇号,我也会丢失前面的零.

我偶然发现,如果我用百分号前缀该东西,Excel会将单元格中的值转换为百分比,所以也许有一些前缀我可以使用它来使Excel在加载它时将单元格中的值作为文本吗?

c# csv excel

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