对于包含长时间运行操作的actor,我遇到了一些麻烦,在我的情况下是持久套接字连接.这里有一些测试代码,如果我创建的实例少于4个,那么运行正常,但是如果我创建更多实例,我总是只有三个或有时四个并发套接字连接,因为其他的超时.我想知道为什么会这样,我的代码是否有明显的错误.
package test
import actors.Actor
import actors.Actor._
import java.io.{PrintStream, DataOutputStream, DataInputStream}
import java.net.{Socket, InetAddress}
import java.text.{SimpleDateFormat}
import java.util.{Calendar}
case class SInput(input: String)
case class SOutput(output: String)
case class SClose
case class SRepeat
import scala.xml._
class Config(xml: Node) {
var nick: String = (xml \ "nick").text
var realName: String = (xml \ "realName").text
var server: String = (xml \ "ip").text
var port: Int = (xml \ "port").text.toInt
var identPass: String = (xml \ "identPass").text
var joinChannels: List[String] = List.fromString((xml \ "join").text.trim, …Run Code Online (Sandbox Code Playgroud) 我将一个工作(postgre)sql查询翻译成jpql,但是hibernate抛出一个
org.hibernate.hql.ast.QuerySyntaxException:意外的AST节点异常
这些是我的核心模型类:
@Entity
public class Piece {
@Id
@GeneratedValue
public Long id;
@ManyToOne
public AUser user;
public long index;
...
}
@Entity
public class Vote {
@Id
@GeneratedValue
public Long id;
@ManyToOne
public AUser receiver;
...
}
@Entity
public class AUser {
@Id
@GeneratedValue
public Long id;
@OneToMany(mappedBy="receiver", cascade=CascadeType.ALL)
public List<Vote> receivedVotes;
...
}
Run Code Online (Sandbox Code Playgroud)
这是我的jpql查询:
String query = "select p from Piece p order by (select count(v.receiver) from Vote v where v.receiver.id=p.user.id) desc, p.index";
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释异常,它为什么会发生以及如何更改查询以避免它.谢谢!