这个表是按月生成的.基本上所有月度表的表结构都是相同的.
因为使用不同的表名映射同一个实体需要做很多工作,
是否可以在运行时更改实体的表名,因为它们毕竟具有相同的表结构?
@Entity
@Table(name="FOO_JAN2010") // any other ways to generate this dynamically?
public class FooJan2010Table { // if we can dynamically set the table name this can be simply named FooTable
...
}
Run Code Online (Sandbox Code Playgroud)
如果没有,你能提出什么方法?
根据这里的Spring文档:
虽然HTTP定义了这四种方法,但HTML只支持两种:GET和POST.幸运的是,有两种可能的解决方法:您可以使用JavaScript来执行PUT或DELETE,或者只使用"real"方法作为附加参数进行POST(在HTML表单中建模为隐藏输入字段).
他们已经完成了后者,并且可以使用以下spring MVC表单标记来实现:
<form:form method="delete">
<input type="submit" value="Delete"/>
</form:form>
Run Code Online (Sandbox Code Playgroud)
问题是,当我单击"删除"时,我的页面会抛出以下错误:
HTTP Status 405 - Request method 'POST' not supported
Run Code Online (Sandbox Code Playgroud)
我将调试级别更改org.springframework.web为debug并找到以下消息:
DEBUG AnnotationMethodHandlerExceptionResolver - Resolving exception from handler [foo.bar.MessageForm@da9246]:
org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported
Run Code Online (Sandbox Code Playgroud)
我使用RestClient和DELETE方法,并按预期调用该方法.我在这做错了什么?
有没有办法使用JPA 2 Criteria API选择特定列?
以下是目标SQL语句:
SELECT column1, column2 FROM MyTableThatHasMultipleColumns
Run Code Online (Sandbox Code Playgroud)
使用Hibernate的Criteria API,这可以使用Projections完成,是否与JPA 2 Criteria Specification相当?