你可以在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
最满意答案
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])
相关问答
更多-
ActiveRecord中的SQL错误(SQL error in ActiveRecord)[2022-10-16]
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: ... -
对Activerecord的SQL查询(Sql query to Activerecord)[2023-08-25]
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 ...
-
Codeigniter:从sql到activerecord,有什么不对?(Codeigniter: from sql to activerecord, what is the wrong?)[2023-06-26]
所以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
-
我可以通过编写SQL而不是ActiveRecord来节省内存吗?(Can I save memory by writing SQL instead of ActiveRecord?)[2024-02-26]
您需要查看该博客文章中的下一段以获取一些上下文: 可以避免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 = ...
-
SQL“in”的相应ActiveRecord“Where”语法是什么?(What is the appropriate ActiveRecord “Where” syntax for SQL “in”?)[2022-04-25]
问题是你发送没有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 ...