我有两个相关的分支JPA注释.报警和状态.一个警报可以有一个状态.
我需要的是能够删除一个状态并将空值"传播"到该状态中已删除的警报.
也就是说,我需要将外键定义为" on delete set null ".
@Entity
public class Alarm {
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="sequence")
@SequenceGenerator(name="sequence", sequenceName="alarm_pk_seq")
private Integer id;
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="idStatus")
private Status status;
// get/set
}
@Entity
public class Status {
@Id
@Column(name="idStatus")
private Integer id;
private String description;
// get/set
}
Run Code Online (Sandbox Code Playgroud)
例:
之前:
STATUS
id description
1 new
2 assigned
3 closed
ALARMS
id status
1 1
2 2
3 2
Run Code Online (Sandbox Code Playgroud)
之后(删除id = 2的状态)
STATUS
id description
1 new
3 closed
ALARMS
id status
1 1 …Run Code Online (Sandbox Code Playgroud) 是否可以src使用jQuery或JavaScript获取当前DOM中图像的实际URL(而不是属性值)?
即检索"example.com/foo.jpg"而不是"foo.jpg"(考虑<base>元素)
那么任何其他有趣的属性,如mime类型,文件大小,或者最重要的是,实际的二进制数据呢?
我已经开始阅读有关单例会话bean和用于使用容器管理并发的注释.与简单地使用'synchronized'关键字相比,我没有看到这样的好处,所以我怀疑有一些重要的东西我不知道.考虑一下Rubinger&Burke,O'Reilly的" Enterprise JavaBeans 3.1 " 一书中的这个例子:
@javax.ejb.Lock(javax.ejb.LockType.READ)
public String concurrentReadOnlyMethod(){...}
@javax.ejb.Lock(javax.ejb.LockType.WRITE)
public void allowOnlyOneWriteAtATimeMethod(String stringToSet){...}
Run Code Online (Sandbox Code Playgroud)
这是怎么比读情况下,所有toghether省略注释和使用更好的synchronized关键字写的情况下,像这样的:
public String concurrentReadOnlyMethod(){...}
public synchronized void allowOnlyOneWriteAtATimeMethod(String stringToSet){...}
Run Code Online (Sandbox Code Playgroud) 我有两个类似的模式,其中只有一个嵌套字段发生更改(onefield在schema1和anotherfieldschema2中调用).
schema1
{
"type": "record",
"name": "event",
"namespace": "foo",
"fields": [
{
"name": "metadata",
"type": {
"type": "record",
"name": "event",
"namespace": "foo.metadata",
"fields": [
{
"name": "onefield",
"type": [
"null",
"string"
],
"default": null
}
]
},
"default": null
}
]
}
Run Code Online (Sandbox Code Playgroud)
SCHEMA2
{
"type": "record",
"name": "event",
"namespace": "foo",
"fields": [
{
"name": "metadata",
"type": {
"type": "record",
"name": "event",
"namespace": "foo.metadata",
"fields": [
{
"name": "anotherfield",
"type": [
"null",
"string"
],
"default": null
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Microsoft Bot Framework与 WhatsApp集成。
我已经有与机器人服务对话的现有机器人(Skype 和网络聊天),并试图创建一个新的通信渠道。
我怎样才能构建这个新频道?
我已经有了可以从 WhatsApp 发送接收消息的 API,我计划在收到用户的消息时挂钩我的机器人服务,但我不知道如何使用我的机器人服务,因为它接受一个类Activity.
是否为struts 2动作类提供了可以在该动作类的每个方法之前调用的init方法?
例如,我有一个struts 2的动作类,如下所示
import com.opensymphony.xwork2.ActionSupport;
public class EmployeeAction extends ActionSupport{
private DepartmentDaoService deptService = new DepartmentDaoService() ;
private EmployeeDaoService empService = new EmployeeDaoService();
private Employee employee;
private List<Employee> employees;
private List<Department> departments;
public void init()
{
//Do initialization stuff here
}
public String getAllEmployees(){
employees = empService.getAllEmployees();
return "success";
}
public String deleteEmployee(){
empService.deleteEmployee(employee.getEmployeeId());
return "success";
}
}
Run Code Online (Sandbox Code Playgroud)
现在,在上面的代码时Struts动作getAllEmployees()和deleteEmplyee()被称为我想init()方法首先执行.我们可以通过从两个函数调用它来运行它.
但是struts 2中是否有任何规定会在每次调用时自动运行init方法,或者struts 2为action clases提供任何此类方法?
如果有人知道,请告诉我.
谢谢.
这是我收听GPS位置更新的方式(使用LocationManager和a LocationListener):
locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
listener = new MyLocationistener(); // LocationListener
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
30000, // milliseconds (minTime)
20, // meters (minDistance)
listener );
Run Code Online (Sandbox Code Playgroud)
但我想动态调整使用的minTime和minDistance参数LocationManager#requestLocationUpdates.我的目标是根据几个使用政策节省电池,即:
我想知道:
LocationManager#removeUpdates并LocationManager#requestLocationUpdates再次,如果是唯一的选择.编辑:应用程序是一个跟踪系统,以了解人们在哪里,以便将任务分配给最接近给定poing的人.实际上电池几乎不会持续8个小时,所以我想增加它.
我正在制作一个基于回合制的RPG游戏,我的方法按照所有"Actor"对象的顺序对所有"Actor"对象进行排序,这些对象完全随机排序.但是,我希望改进这种方法,以便每个演员都拥有的"敏捷"数据能够提高他们的成绩.我已经查看了Collections类和Arrays中的几个方法,但似乎没有找到任何符合我想要的方法.
现在,我正在考虑获得1到100之间的随机int,并且敏捷得分可以提高几率.我为整数和一个HashMap尝试了单独的ArrayLists ......但是没有继续使用它们.
我现在的方法是:
// getFriendlies(), getHostiles(), and attack_order are all ArrayLists
public void calculateAttackOrder() {
attack_order.addAll(getFriendlies());
attack_order.addAll(getHostiles());
Collections.shuffle(attack_order);
}
Run Code Online (Sandbox Code Playgroud)
我很感激帮助!
我正在尝试json序列化一个MyRootClass类,其属性是第二个类MyClass的元素集合:
public class MyRootClass {
private List<MyInterface> list = new ArrayList<MyInterface>();
// getter / setter
}
public class MyClass implements MyInterface {
private String value = "test";
// getter / setter
}
Run Code Online (Sandbox Code Playgroud)
以下代码:
MyRootClass root = new MyRootClass();
root.getList().add(new MyClass());
ObjectMapper mapper = new ObjectMapper();
mapper.writeValue(System.out, root);
Run Code Online (Sandbox Code Playgroud)
生成此JSON输出:
{"list": [ {"value":"test"} ] }
Run Code Online (Sandbox Code Playgroud)
而不是我需要的,集合中的每个对象都用一个名称序列化:
{"list": [ {"myclass": {"value":"test"}} ] }
Run Code Online (Sandbox Code Playgroud)
有没有办法用Jackson实现它?我考虑过编写自定义序列化程序,但是我没有找到任何与对象集合相关的内容.
java ×6
algorithm ×1
android ×1
avro ×1
botframework ×1
bots ×1
collections ×1
concurrency ×1
ejb-3.1 ×1
foreign-keys ×1
hibernate ×1
jackson ×1
javascript ×1
jpa ×1
jquery ×1
json ×1
orm ×1
primary-key ×1
sorting ×1
sql ×1
struts2 ×1
whatsapp ×1