我正在使用,hibernate但我听说这spring-data-jpa是最好的,所以我尝试它,我很满意,直到我面对这个问题.
我在我的搜索表单中jsp有许多标准,用户可以选择他想要的任何内容.
那么这个请求的等价物是什么呢? spring-data-jpa
if(startDate!=null){
criteria.add(Expression.ge("date",startDate));
}
if(endDate!=null){
criteria.add(Expression.le("date",endDate));
}
if(volume!=null){
criteria.add(Expression.ge("volume",volume));
}
if ....
Run Code Online (Sandbox Code Playgroud) 我下载mysql-5.7.9-winx64.zip,当我尝试运行时,mysqld我收到此错误:
E:\Softwares\mysql-5.7.9-winx64\bin>mysqld
mysqld: Could not create or access the registry key needed for the MySQL application
to log to the Windows EventLog. Run the application with sufficient
privileges once to create the key, add the key manually, or turn off
logging for that application.
mysqld: Can't change dir to 'E:\Softwares\mysql-5.7.9-winx64\data\' (Errcode: 2 - No such file or directory)
2015-11-13T10:45:09.715411Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_ti
mestamp server option (see documentation …Run Code Online (Sandbox Code Playgroud) 我发送多个文件以formData这样的
在我的Spring MVC Controller中
@PostMapping(value = "/marches")
public Integer saveMarches(
@RequestPart("formJson") FooBean formJson,
@RequestPart("attachOs") MultipartFile[][] attachOs
) throws IOException {
...
}
Run Code Online (Sandbox Code Playgroud)
我的conf:
@Bean(name = "multipartResolver")
public CommonsMultipartResolver multipartResolver() {
CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
multipartResolver.setMaxUploadSize(30000000);
return multipartResolver;
}
Run Code Online (Sandbox Code Playgroud)
但是我400 Bad Request在浏览器中找到了
在IDE中,我得到了:
Run Code Online (Sandbox Code Playgroud)Resolved [org.springframework.web.multipart.support.MissingServletRequestPartException: Required request part 'attachOs' is not present]
如果我尝试,@RequestPart("attachOs[][]") MultipartFile[][] attachOs我总是收到一个不好的要求Required request part 'attachOs[][]' is not present
问题是显而易见的:春天只是在寻找attachOs部分(@RequestPart("attachOs")),但我发送attachOs[0][0],attachOs[0][1]...
当我只发送formJson …
我有这样的托管bean:
@ManagedBean
@SessionScoped
public class utilisateur implements Serializable {
private String login ="yous" ;
private String password ="yous";
...
...
}
Run Code Online (Sandbox Code Playgroud)
和我的login.xhtml
<h:outputText value="login: " />
<p:inputText value="#{utilisateur.login}" />
<h:outputText value="password: " />
<p:password value="#{utilisateur.password}" />
Run Code Online (Sandbox Code Playgroud)
因此,使用此配置时,密码必须默认显示为****(yous)in,p:password但它显示为空.
1 - 会话变量存储在java Web应用程序中的哪些位置?在客户端或服务器端?
2 - 如果我在会话中放入了大量对象和变量,它会减慢客户端的请求吗?
PS在我的情况下,我使用spring mvc.
我使用querydsl这就是为什么我不需要方法findByName(),我的所有存储库接口都是空的.
所以我尝试制作genric代码以避免重复的空方法接口,因为我在hibernate映射的实体中有很多类.
public interface GenericResposotory<T>
extends JpaRepository<T, Integer>, QueryDslPredicateExecutor<T> {
}
Run Code Online (Sandbox Code Playgroud)
当我运行我的服务器时,我收到此错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'genericResposotory':
Invocation of init method failed; nested exception is
java.lang.IllegalArgumentException: Not an managed type: class java.lang.Object
Run Code Online (Sandbox Code Playgroud)
还有没有办法像我尝试做一个通用的存储库?
如何在jquery datepicker 的标题中显示当前的完整日期,如下所示:
05 July 2015 因为它只是告诉我 July 2015

根据React文档:
当您具有涉及多个子值的复杂状态逻辑或下一个状态取决于前一个状态时,useReducer 通常比 useState 更可取。
1.有人能解释一下为什么useReducer不同步更新状态吗?
const reducer = (state, action) => {
if( action.type === 'ADD_VALUE') {
console.log(`STATE IN REDUCER`, [...state, action.path]) // => ["1.1"]
return [...state, action.path]
}
}
const [state, dispatch] = useReducer(reducer, [])
<input type="button" onClick={() => {
dispatch({ type: 'ADD_VALUE', path: "1.1"})
console.log(`STATE`, state) // => []
// here i want to do some stuff based on the lastest updated state (["1.1"] and not [])
// for example dispatch an …Run Code Online (Sandbox Code Playgroud) 有什么区别
position : relative;
bottom : 10px;
Run Code Online (Sandbox Code Playgroud)
而且:
margin-top: -10px;
Run Code Online (Sandbox Code Playgroud)
在我看来他们是一样的不是?
如何QueryDsl在查询JPA中使用此功能
SUBSTRING_INDEX(str,delim,count)
Run Code Online (Sandbox Code Playgroud)
str在count出现分隔符之前从字符串返回子字符串delim.
更新1: 尝试@MaciejDobrowolski之后的解决方案:
QAcheteur ach = new QAcheteur("ach");
new JPAQuery(entityManager).from(ach)
.list( Expressions.stringTemplate("SUBSTRING_INDEX({0},',',1)", ach.ancestors) );
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'SUBSTRING_INDEX' {originalText=SUBSTRING_INDEX}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[DOT] DotNode: 'acheteur1_.ancestors' {propertyName=ancestors,dereferenceType=PRIMITIVE,getPropertyPath=ancestors,path=ach.ancestors,tableAlias=acheteur1_,className=persistence.Acheteur,classAlias=ach}
| +-[ALIAS_REF] IdentNode: 'acheteur1_.ID_ACHETEUR' {alias=ach, className=persistence.Acheteur, tableAlias=acheteur1_}
| \-[IDENT] IdentNode: 'ancestors' {originalText=ancestors}
+-[QUOTED_STRING] LiteralNode: '',''
\-[NUM_INT] LiteralNode: '3'
Run Code Online (Sandbox Code Playgroud)
更新2 :(解决方案)
关注@DraganBozanovic的回答我创建我的自定义方言来获取No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode因为SUBSTRING_INDEX未知JPA因此我们使用自己的方言使其工作.
package dialect;
import …Run Code Online (Sandbox Code Playgroud) hibernate ×3
java ×3
javascript ×3
spring ×3
jpa ×2
querydsl ×2
spring-data ×2
spring-mvc ×2
criteria ×1
css ×1
datepicker ×1
jquery ×1
jsf ×1
jsf-2 ×1
mysql ×1
passwords ×1
primefaces ×1
reactjs ×1
servlets ×1
session ×1