我正在用C#编写桌面项目.我正在使用Nhibernate与数据库进行通信.此外,我使用FluentNhibernate进行模型映射,但我陷入了映射的某些部分.这是ProductMap中的My mapping Class
松动地图
public LosingMap()
{
Id(x => x.id);
Map(x => x.reason);
Map(x => x.quantity);
Map(x => x.lose_sum);
Map(x => x.rate);
Map(x => x.deleted);
Map(x => x.create_date);
Map(x => x.update_date);
References(x => x.currency).Column("CurrencyCode");
Table("Loosing");
}
}
Run Code Online (Sandbox Code Playgroud)
这是CurrencyMap
CurrencyMap
public CurrencyMap()
{
Id(x => x.id);
Map(x => x.code).UniqueKey("currency_code");
Map(x => x.name);
Map(x => x.shname);
Map(x => x.symbol);
Map(x => x.deleted);
HasMany(x => x.Losings).Cascade.All();
Table("currency");
}
}
Run Code Online (Sandbox Code Playgroud)
这里是我在我的货币表中有一个主键和一个唯一键我怎么能在我的LoosingMap类中引用我的唯一而不是主键???
用Java创建了新的API。我想使用该API的方法,例如post,get方法,但无法正常工作。能否给我提示使用其他方法来做到这一点。
URI url = URI.create("http://localhost:8080/departure/");
System.out.println("koraylikchi");
HttpPost httpPost = new HttpPost(url);
JSONObject jsonObject = new JSONObject();
jsonObject.put("departDate",dateChooser.getPromptText());
jsonObject.put("time",timeField.getText());
jsonObject.put("flight",flightField.getText());
jsonObject.put("destination",destField.getText());
jsonObject.put("statusTime",statusTimeField.getText());
jsonObject.put("terminal",terminalField.getText());
try {
StringEntity se = new StringEntity(jsonObject.toString());
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
httpPost.setEntity(se);
HttpClient client = new HttpClient();
int response = client.executeMethod((HttpMethod) httpPost);
System.out.println(response);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
});
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误
Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: org.apache.http.client.methods.HttpPost cannot be cast to org.apache.commons.httpclient.HttpMethod
at controllers.AddDialogDepatureController.lambda$onClick$7(AddDialogDepatureController.java:190) …
Run Code Online (Sandbox Code Playgroud) 当我将新的 @RequestMapping 方法添加到控制器时,@Autowired 突然停止工作。为什么我不明白。当我尝试使用这个新方法时,所有 @Autowired 接口都变为空。当我将其他 @RequestMapping 用于其他方法时,一切正常。
当我尝试使用新的@RequestMapping 时,第一张图片显示所有@Autowired 类为空。
这我使用其他@RequestMapping 都可以完美运行。这是 spring Rest Api 应用程序。我以前没有遇到过这些事情。什么可能是这样的应用程序。