ArangoDB高级教程——ArangoDB3.3.19整合Springboot2.1.0

ArangoDB安装见 https://blog.csdn.net/w690333243/article/details/83626273
Springboot使用2.1.0
moven项目中 pom.xml中添加如下配置

<dependency>
			<groupId>com.arangodb</groupId>
			<artifactId>arangodb-spring-boot-starter</artifactId>
			<version>1.0.0</version>
		</dependency>

官方demo spring-data-demo:https://github.com/arangodb/spring-data-demo

Couldn’t find PersistentEntity for type class java.lang.Long!
问题原因:
AccountInfo.java 中定义 Long account;
查询获取最大account.
错误写法

@Query("FOR c IN t_accountinfo COLLECT AGGREGATE maxAccount = MAX(c.account) RETURN {maxAccount}")
	Long getLatestAccount();

正确写法

@Query("FOR c IN t_accountinfo COLLECT AGGREGATE maxAccount = MAX(c.account) RETURN maxAccount")
	Long getLatestAccount();

问题所在:
return {maxAccount}返回的是一个json对象,并不是long对象
return maxAccount 返回的是long对象

userinfo,shuoshuo 两个表联合查询:查询表中所有的项,即 a.account,a.name,b.conteng,b.time

  FOR shuoshuo IN t_shuoshuo
    FOR userinfo IN t_userinfo 
    FILTER shuoshuo.account == userinfo.account
    RETURN MERGE(shuoshuo, userinfo)

二、查询说说中所有项,userinfo中两项

FOR shuoshuo IN t_shuoshuo 
  RETURN   { 
    shuoshuo: shuoshuo, 
    userinfo: (
      FOR userinfo IN t_userinfo
        FILTER userinfo.account == shuoshuo.account
        RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname}
    )
  }

排序查询说说

FOR shuoshuo IN t_shuoshuo  SORT shuoshuo._key DESC 
    RETURN   {
        shuoshuo: shuoshuo,
                userinfo: (
                FOR userinfo IN t_userinfo
        FILTER userinfo.account == shuoshuo.account 
        RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline}
    )
    }

通过id查询 说说

FOR shuoshuo IN t_shuoshuo FILTER  shuoshuo._key ==  @id
    RETURN   {
        shuoshuo: shuoshuo,
                userinfo: (
                FOR userinfo IN t_userinfo
        FILTER userinfo.account == shuoshuo.account 
        RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline}
    )
    }

查询说说,说说点赞,说说发表人信息

FOR shuoshuocomment IN t_shuoshuocomment FILTER  shuoshuocomment.shuoshuoId == "868629"  SORT shuoshuocomment._key DESC 
					        RETURN   {
						        shuoShuoComment: shuoshuocomment,
						        shuoShuoCommentReplyList: (
						                FOR shuoshuocommentreply IN t_shuoshuocommentreply 
						       FILTER shuoshuocommentreply.rootCommentId == shuoshuocomment._key 
						        RETURN {
							shuoShuoCommentReply:shuoshuocommentreply,
							replyUserInfo: ( FOR userinfo IN t_userinfo 
			     FILTER userinfo.account == shuoshuocommentreply.account 
			   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} )
							}
						    ),

						     commentUserInfo: ( FOR userinfo IN t_userinfo 
			     FILTER userinfo.account == shuoshuocomment.account 
			   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} )
						    }

回复 评论计数统计

FOR shuoshuocomment IN t_shuoshuocomment FILTER  shuoshuocomment.shuoshuoId == "868629"  SORT shuoshuocomment._key DESC 
					        RETURN   {
						        shuoShuoComment: shuoshuocomment,
						        shuoShuoCommentReplyList: (
						                FOR shuoshuocommentreply IN t_shuoshuocommentreply 
						       FILTER shuoshuocommentreply.rootCommentId == shuoshuocomment._key 
						        RETURN {
							shuoShuoCommentReply:shuoshuocommentreply,
							replyUserInfo: ( FOR userinfo IN t_userinfo 
			     FILTER userinfo.account == shuoshuocommentreply.account 
			   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} )
							}
						    ),

						     commentUserInfo: ( FOR userinfo IN t_userinfo 
			     FILTER userinfo.account == shuoshuocomment.account 
			   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} ),
      commentnumber: (FOR shuocomment IN t_shuoshuocomment
						  FILTER shuocomment.shuoshuoId == "868629"
						  COLLECT  WITH COUNT INTO commentnumber RETURN commentnumber) ,
replynumber: (FOR shuoreply IN t_shuoshuocommentreply
						  FILTER shuoreply.shuoshuoId == "868629"
						  COLLECT  WITH COUNT INTO replynumber RETURN replynumber) 
						    }
FOR shuoshuocomment IN t_shuoshuocomment FILTER  shuoshuocomment.shuoshuoId == "868629"  SORT shuoshuocomment._key DESC 
					        RETURN   {
						        shuoShuoComment: shuoshuocomment,
						        shuoShuoCommentReplyList: (
						                FOR shuoshuocommentreply IN t_shuoshuocommentreply 
						       FILTER shuoshuocommentreply.rootCommentId == shuoshuocomment._key 
						        RETURN {
							shuoShuoCommentReply:shuoshuocommentreply,
							replyUserInfo: ( FOR userinfo IN t_userinfo 
			     FILTER userinfo.account == shuoshuocommentreply.account 
			   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} )
							}
						    ),

						     commentUserInfo: ( FOR userinfo IN t_userinfo 
			     FILTER userinfo.account == shuoshuocomment.account 
			   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} ),
      commentnumber: (FOR shuocomment IN t_shuoshuocomment
						  FILTER shuocomment.shuoshuoId == "868629"
						  COLLECT  WITH COUNT INTO commentnumber RETURN commentnumber) ,
replynumber: (FOR shuoreply IN t_shuoshuocommentreply
						  FILTER shuoreply.shuoshuoId == "868629"
						  COLLECT  WITH COUNT INTO replynumber RETURN replynumber) 
						    }

评论回复点赞,点赞计数

FOR shuoshuocomment IN t_shuoshuocomment FILTER  shuoshuocomment.shuoshuoId == "2554321"  SORT shuoshuocomment.date DESC 
					        RETURN   {
									        shuoShuoComment: shuoshuocomment, 
									        shuoShuoCommentReplyList: (
									                FOR shuoshuocommentreply IN t_shuoshuocommentreply 
									       FILTER shuoshuocommentreply.rootCommentId == shuoshuocomment._key 
									        RETURN {
										shuoShuoCommentReply:shuoshuocommentreply,
likenumber: (FOR shuocommentreplylike IN t_shuoshuocommentlike
						  FILTER shuocommentreplylike.commentId ==  shuoshuocommentreply._key
						  COLLECT  WITH COUNT INTO likenumber RETURN likenumber), 
			     ismyliked: (FOR shuocommentreplylike IN t_shuoshuocommentlike
						  FILTER shuocommentreplylike.commentId == shuoshuocommentreply._key AND shuocommentreplylike.account =="10004"
						  COLLECT  WITH COUNT INTO ismyliked RETURN ismyliked) ,

										replyUserInfo: ( FOR userinfo IN t_userinfo 
						     FILTER userinfo.account == shuoshuocommentreply.account 
						   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} )
										}),
									     commentUserInfo: ( FOR userinfo IN t_userinfo 
						     FILTER userinfo.account == shuoshuocomment.account 
						   RETURN {avatarurl:userinfo.avatarurl,nickname:userinfo.nickname,isonline:userinfo.isonline} ),
			      likenumber: (FOR shuocommentlike IN t_shuoshuocommentlike
						  FILTER shuocommentlike.commentId ==  shuoshuocomment._key
						  COLLECT  WITH COUNT INTO likenumber RETURN likenumber), 
			     ismyliked: (FOR shuocommentlike IN t_shuoshuocommentlike
						  FILTER shuocommentlike.commentId == shuoshuocomment._key AND shuocommentlike.account == "10004"
						  COLLECT  WITH COUNT INTO ismyliked RETURN ismyliked) 
									    }

更新于2018年12月4日 23:49
https://www.arangodb.com/arangodb-training-center/search/

更新于2018年11月18日
https://docs.arangodb.com/devel/AQL/Operations/Collect.html
https://www.arangodb.com/tutorials/mongodb-to-arangodb-tutorial/
https://www.arangodb.com/arangodb-training-center/search/
https://www.arangodb.com/documentation/
https://www.arangodb.com/why-arangodb/arangodb-vs-neo4j/
https://www.arangodb.com/arangodb-training-center/tutorials-aql-query-profiling/

https://blog.csdn.net/l1028386804/article/details/72801492 nginx+keepalived搭建高可用负载均衡
https://blog.csdn.net/qq_34021712/article/details/73441168 nginx+keepalived搭建高可用负载均衡
https://www.daimafans.com/article/d4807910888570880-p1-o1.html ArangoDB 入门指南:查询数据库
https://blog.csdn.net/yuzongtao/article/details/75968752?utm_source=blogxgwz2 ArangoDB高级操作
https://blog.csdn.net/tuntunwang/article/details/78893712 推荐系统实践—第六章:利用社交网络数据
https://cloud.tencent.com/developer/ask/65232/answer/111071
更新于2018年12月09日 0:10 周日凌晨
周四晚上,工作发生变动,记住,努力,就是为了有一天,无论发生任何事,都可以无所畏惧
更新于2019年5月2日 星期四 17:21 五一放假的第二天,来公司处理问题 sdy

https://www.cnblogs.com/litufu/articles/9650884.html ArangoDB 学习笔记 (2)数据模型
https://www.cnblogs.com/litufu/articles/9645300.html ArangoDB 学习笔记(1)入门篇
https://www.cnblogs.com/litufu/articles/9651068.html ArangoDB 学习笔记 (3)命名规范
https://www.arangodb.com/tutorials/cn-tutorial-sync-java-driver/

今天遇到一个问题,插入数据时总是报冲突:

arangodb  idx_  over conflict

之前这样写的实体类:

@Document("t_user")
@HashIndex(fields = { "account" }, unique = true)
public class AccountInfo implements Serializable {

后来改成了这样的(改之前已经有t_user表了,表信息的索引已经生成了,改后没有删除原来的数据表,导致有问题,删除表,从新生成表解决问题)

@Document("t_user")
@HashIndex(fields = { "userId" }, unique = true)
@HashIndex(fields = { "telephone" }, unique = true)
public class AccountInfo implements Serializable {

情景:刚开始设置了account为索引,并且是唯一索引。后来改掉了account为userId,但是改后数据表还在,改后插入数据时一直报索引冲突,over之类的,后来删除表,重新生成表,就没问题了
https://blog.csdn.net/zaishijizhidian/article/details/91969864
更新于2020年11月22日22:04 ylxy3eefzt

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值