草庐IT

data-tools-id

全部标签

java - 在 Spring Data JPA 中使用注释连接两个以上的表

我有三个实体:A、B和C,它们之间的关系如下:classA{@ManyToManyListbs;//otherattributesandgettersetters}classB{@ManyToManyListcs;//otherattributesandgettersetters}classC{//otherattributesandgettersetters}但是从我当前的实体类中,我可以使用@JoinTable在任意2个表之间建立关系。但我想要的是将所有3个实体之间的关系保存在一个单独的表中,将这些实体的主键作为列。(外键)如果我们假设实体B和C已经保存(插入)到数据库中,我将插入

java - 最佳实践 : Where to resample PCM and which tool?

我开发了一个内核模块(Android),它为我提供:PCM16-bit48000Hz2channel我想用java将其流式传输到Apple的机场快线(AEX)。AEX需要44.1kHzPCM,所以我必须重新采样PCM流。我有以下几种可能性,但哪种是最好的?1。使用C程序“raop_play”(raop-play的一部分)advantages:high-performantduetonativeCalreadyuseslibsampleratetoresamplewav,mp3,ogg,flac,aac,plsopensslasstaticlibraryusableviacommand-

java - 左加入 spring data jpa 和 querydsl

我正在使用springdatajpa和querydsl,并且陷入了如何编写简单的查询以左连接两个表的问题。假设我有一个Project实体和一个在Project中定义了OneToMany关系的Task实体,我想做类似的事情:select*fromprojectpleftjointasktonp.id=t.project_idwherep.id=searchTermselect*fromprojectpleftjointasktonp.id=t.project_idwheret.taskname=searchTerm在JPQL中,它应该是:selectdistinctpfromProjec

java - 无法为我的实体生成 UUID ID

我正在使用以下工具开发Web项目:Spring4.x(SpringBoot1.3.3)hibernate4.xPostgreSQL9.x我是PostgresDB的新手,对于我的表,我决定(第一次)使用UUID标识符,但我遇到了一些麻烦......对于ID字段,我使用了Postgresuuid类型,并将uuid_generate_v4()设置为默认值。当我直接通过PSQL插入生成新行时,一切正常,但我无法通过我的应用程序创建新记录。例如,这是我在应用程序中声明实体的方式:@Entity@Table(name="users")publicclassUser{@Id@Type(type="p

分布式ID选型对比(2)

数据库号段模式一,引入依赖:mysqlmysql-connector-java8.0.19org.mybatis.spring.bootmybatis-spring-boot-starter2.2.2二,新建表CREATETABLE`id_generator`(`id`intNOTNULL,`max_id`bigintNOTNULLCOMMENT'当前最大id',`step`intNOTNULLCOMMENT'号段的布长',`biz_type`intNOTNULLCOMMENT'业务类型',`version`intNOTNULLCOMMENT'版本号',PRIMARYKEY(`id`))ENG

java - 父类中@Id 和基类中唯一序列的正确 JPA 映射是什么

我有一个类层次结构:abstractDomainObject{...@Id@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="SEQ")@SequenceGenerator(name="SEQ",sequenceName="SEQ_DB_NAME")@Column(name="id",updatable=false,nullable=false)privateLongid;...}BaseClassextendsDomainObject{...//Fillinblankherewherethisclass's@Idwi

java - 合并实体,更改其id,再次合并,导致 "mapped to a primary key column in the database. Updates are not allowed"错误

我有一个JPA程序,其中EclipseLink是持久性提供程序。当我合并用户实体、更改其ID并尝试再次合并同一用户实例时,会引发错误。我重写了我的代码,以最简单的方式说明我的问题。Useruser=userManager.find(1);userManager.merge(user);System.out.println("Userismanaged?"+userManager.contains(user);user.setId(2);userManager.merge(user);以上代码不在事务上下文中。userManager是一个注入(inject)了EntityManager的

java - 如何在 spring-data 中使用 CrudRepository 强制预加载?

我有一个包含List的实体,因此默认加载lazy:interfaceMyEntityRepositoryextendsCrudRepository{}@EntitypublicclassMyEntity{@IdprivateLongid;@OneToMany(mappedBy="bar")//lazybydefaultprivateListbars;}@EntitypublicclassBar{//somemore}问题:如何在执行repository.findOne(id)时强制预加载? 最佳答案 您可以使用leftjoinfet

java - 手动分配 ID 时,Spring Data MongoDB 注释 @CreatedDate 不起作用

我正在尝试使用审计在我的对象中保存dateCreated和dateUpdated,但是由于我手动设置了ID,所以还有一些额外的工作。遵循OliverGierke在DATAMONGO-946中的建议我正在尝试弄清楚如何正确实现它。作为上述Jira任务中的原始发布者,我从这里下载了示例https://github.com/spring-guides/gs-accessing-data-mongodb.git并对其进行了一些修改:packagehello;importorg.springframework.data.annotation.CreatedDate;importorg.sprin

java - Spring Data Neo4j 4 中的分页和排序

SDN4中的自定义查询是否支持分页?如果是,它是如何工作的?如果没有,是否有变通办法?我有以下SpringDataNeo4j4存储库:@RepositorypublicinterfaceTopicRepositoryextendsGraphRepository,IAuthorityLookup{//othermethodsomitted@Query("MATCH(t:Topic)-[:HAS_OFFICER]->(u:User)"+"WHEREt.id={0}"+"RETURNu")publicPagetopicOfficers(LongtopicId,Pageablepageable