草庐IT

query-variables

全部标签

java - IntelliJ IDEA 无法解析 spring data jpa @query 注释中的实体

这是我的repository界面:publicinterfaceContentRepositoryextendsJpaRepository{@Query(value="selectcfromContentcwherec.ContentCategory.genre=:genreandc.ContentType.genre=:contentType")IterablefindByTypeAndCategory(@Param("contentType")StringcontentType,@Param("genre")Stringgenre);}这是内容POJO:@Entity@Table(

java - 有没有办法在 Spring Data @Query 注释值中使用常量?

我不想硬编码常量值,我宁愿通过引用变量来指定它们。例如,而不是编写下一个查询:@Query(value="SELECTuFROMUserModeluWHEREu.status=1")..我想提取硬编码值'1'并编写如下内容:@Query(value="SELECTuFROMUserModeluWHEREu.status=UserModel.STATUS_ACTIVE")//doesn'tcompile有没有办法像第二个例子那样在spring-data查询中指定常量? 最佳答案 你必须像这样使用完全限定的类名:@Query("SELE

Spring + hibernate : Query Plan Cache Memory usage

我正在使用最新版本的SpringBoot编写应用程序。我最近遇到了堆增长的问题,即不能被垃圾收集。使用EclipseMAT对堆的分析表明,在运行应用程序的一小时内,堆增长到630MB,而Hibernate的SessionFactoryImpl使用了整个堆的75%以上。我正在寻找可能的查询计划缓存周围的资源,但我发现的唯一内容是this,但这并没有发挥出来。属性设置如下:spring.jpa.properties.hibernate.query.plan_cache_max_soft_references=1024spring.jpa.properties.hibernate.query

java - Spring 数据 JPA : Query by Example?

使用SpringDataJPA我可以做一个querybyexample在哪里使用特定实体实例作为搜索条件?例如(没有双关语),如果我有一个Person实体,看起来像:@EntitypublicclassPerson{privateStringfirstName;privateStringlastName;privatebooleanemployed;privateLocalDatedob;...}我可以找到所有姓氏为Smith出生于1977年1月1日的雇员,例如:Personexample=newPerson();example.setEmployed(true);example.se

java - Spring Web MVC : Use same request mapping for request parameter and path variable

有没有办法表示我的SpringWebMVCController方法应该通过将ID作为URI路径的一部分提交的请求来匹配...@RequestMapping(method=RequestMethod.GET,value="campaigns/{id}")publicStringgetCampaignDetails(Modelmodel,@PathVariable("id")Longid){...或者如果客户端将ID作为HTTP请求参数以样式发送...@RequestMapping(method=RequestMethod.GET,value="campaigns")publicStrin

Spring MVC : how to indicate whether a path variable is required or not?

我正在做一个Spring网络。对于Controller方法,我可以使用RequestParam来指示是否需要参数。例如:@RequestMapping({"customer"})publicStringsurveys(HttpServletRequestrequest,@RequestParam(value="id",required=false)Longid,Mapmap)我想使用如下的PathVariable:@RequestMapping({"customer/{id}"})publicStringsurveys(HttpServletRequestrequest,@PathVa

mysql - "Ignoring query to other database"命令行

在命令提示符MySQL中执行any查询时,我不断收到这条奇怪的消息。ignoringquerytootherdatabase我已经尝试通过发出"usedatabase_name"命令来更改数据库。 最佳答案 好吧,看来我错过了用户的“u”标志,所以我不小心输入了以下命令。mysql-root-p//Faultyconnection而不是...mysql-uroot-p//Correctconnection请注意故障连接中缺少的“u”。 关于mysql-"Ignoringquerytoot

mysql - SELECT INTO 和 "Undeclared variable"错误

当我尝试执行以下查询时:SELECTid_subscriberINTOnewsletter_to_sendFROMsubscribers我收到一个错误:#1327-Undeclaredvariable:newsletter_to_send那个查询有什么问题? 最佳答案 INSERT...SELECThttp://dev.mysql.com/doc/refman/5.1/en/insert-select.htmlINSERTINTOnewsletter_to_sendSELECTid_subscriberFROMsubscribers

mysql - SQL : What is the default Order By of queries?

不使用ORDERBY时查询的默认顺序是什么? 最佳答案 不存在这样的订单。取自http://forums.mysql.com/read.php?21,239471,239688#msg-239688DonotdependonorderwhenORDERBYismissing.AlwaysspecifyORDERBYifyouwantaparticularorder--insomesituationstheenginecaneliminatetheORDERBYbecauseofhowitdoessomeotherstep.GROUP

java - Spring Data MongoDB : How to Dump Raw Query/Commands generated through QueryDsl?

我正在使用SpringData'sQuerydslintegration使用谓词执行我的查询。findAll(predicate,pageable)有没有办法转储实际执行的原始查询/命令?我也看过这个问题的答案,但它对我不起作用..ConfigureloggingfortheMongoDBJavadriver--更新--我设法通过添加logging.level.org.mongodb.driver=DEBUG来使日志记录工作在application.properties(不是log4j.properties)中但是,我仍然看不到正在执行的原始查询:2016-03-2321:50:56D