首页 \ 问答 \ 你可以在Spring TaskExecutors中使用Future / Futuretask对象吗?(Can you use Future/Futuretask objects with Spring TaskExecutors?)

你可以在Spring TaskExecutors中使用Future / Futuretask对象吗?(Can you use Future/Futuretask objects with Spring TaskExecutors?)

是否有可能使用Java FutureTask和Spring TaskExecutor来获取Future对象?

我正在寻找一个实现Java ExecutorService接口的TaskExecutor,特别是submit()方法。 透过Spring看看Javadocs并没有透露任何这样的类。 是否有一些备选方法可以通过Spring TaskExecutors处理未来的未知情况?

如果可能的话,你还可以加入一个例子吗?


Is it possible to use Java FutureTask with a Spring TaskExecutor to get a Future object?

I'm looking for a TaskExecutor that implements the Java ExecutorService interface, in particular the submit() method. Looking through the Spring Javadocs doesn't reveal any classes like this. Is there some alternate method to handle futures through Spring TaskExecutors that I am unaware of?

If it is possible, could you also include an example?


原文:https://stackoverflow.com/questions/883533
更新时间:2023-12-15 12:12

最满意答案

KEY是一个保留字,所以你必须逃避它:

@profiles = UserProfile.where("`key` = ? and id in (?)", 'Noc_Address', session[:profile_ids])

或者让Rails为您处理:

@profiles = UserProfile.where(key: 'Noc_Address', id: session[:profile_ids])

KEY is a reserved word so you have to escape it:

@profiles = UserProfile.where("`key` = ? and id in (?)", 'Noc_Address', session[:profile_ids])

Or let Rails handle this for you:

@profiles = UserProfile.where(key: 'Noc_Address', id: session[:profile_ids])

相关问答

更多
  • KEY是一个保留字,所以你必须逃避它: @profiles = UserProfile.where("`key` = ? and id in (?)", 'Noc_Address', session[:profile_ids]) 或者让Rails为您处理: @profiles = UserProfile.where(key: 'Noc_Address', id: session[:profile_ids]) KEY is a reserved word so you have to escape it: ...
  • User.joins("INNER JOIN clients ON clients.user_id <> users.id AND clients.user_id = #{@cliente.id}") User.joins("INNER JOIN clients ON clients.user_id <> users.id AND clients.user_id = #{@cliente.id}")
  • ActiveRecord的MySQL连接默认只能执行一个语句。 要执行多个语句,需要在创建连接时将CLIENT_MULTI_STATEMENTS (65536)作为选项传递。 代码可能如下所示: ConnectionAdapters::MysqlAdapter.new(mysql, logger, [host, username, password, database, port, socket, 65536], config) 您可以在mysql gem中找到ConnectionAdapters::My ...
  • 您的模型中似乎有一个序列化列。 像这样的东西: serialize :parameters 。 这意味着数据不是以易于阅读的格式存储在数据库中,这导致您无法对其进行查询。 和这里一样 。 解决方案:提取要查询的字段,并为其创建列。 It seems that you have a serialized column in your model. Something like this: serialize :parameters. This means the data is stored in the d ...
  • 所以1.删除'from'第2行。连接错误 尝试这个: public function kucuk_ilan($durum ='3') // $durum:1=>tümü 2=>kiralık 3=>satılık 4=>takas { $query = $this->db->select('emlakilan.id, emlakdurum.durum, emlaktip.tip, semtler.semt, emlakilan.fiyat, emlakilan.tarih, resim.r1 ...
  • 假设Cases.assigned_id是你告诉Rails的外键你用来与Employees表关联,你所要做的就是: Employee.joins(:cases).group(:name).count 如果Cases.assigned_id不是Rails正在使用的外键,那么这将不起作用。 在这种情况下,您可以修改SQL并将ON切换为ON ,Postgres会很高兴: @report_b = Case.find_by_sql(" SELECT Employees.name, COUNT(*) AS cnt ...
  • 应用未应用迁移的正确命令是RAILS_ENV=development rake db:migrate Ok the answer is very simple!Just try migrating your DB to version=0 with command: rake db:migrate VERSION=0 and then run rake db:migrate
  • 您需要查看该博客文章中的下一段以获取一些上下文: 可以避免ActiveRecord开销的一个示例是批量更新。 下面的代码既不会实例化任何模型,也不会运行验证和回调。 Book.where('title LIKE ?', '%Rails%').update_all(author: 'David') 作者并不是说你应该使用原始SQL将数据(作为一堆哈希)提取到Rails而不是使用ActiveRecord将数据拉入Rails(作为一堆模型),他们说你不应该从数据中提取大量数据,在Rails中对其进行操作,然后在 ...
  • 如果使用ActiveRecord,必须有更好的方法来做你想要做的事情......但是,如果你因某些原因需要支持你的string_selector功能,我至少会使用Arel: def string_selector(k, v) tbl = Arel::Table.new(:test) # your table, or you could pass this in... condition = case v when /\|/ vals = v.split(/\|/) first = ...
  • 问题是你发送没有parens的列表。 @comment_notifications = Comment.where(["author_id != ? and post_id in (?)", , current_user.id, user_posts_id]) 如果您查看错误,它会告诉您问题接近“1”,这是列表中的第一项。 The problem is that you are sending the list without parens. @comment_notifications = Comm ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。