草庐IT

flight_data_copy_version

全部标签

java - Spring Data Rest JPA - 无法延迟加载 OneToMany 双向关系

我有两个实体,Company和Job,具有OneToMany双向关系。我的问题是我不能延迟加载公司的Listjobs.例如当我这样做时:获取/api/companies/1这是JSON响应:{"id":1,"name":"foo",..."_embedded":{"jobs":[{...},...{...}],"employees":[{...},{...}]},"_links":{"self":{"href":"http://localhost:8080/api/companies/1"},"jobs":{"href":"http://localhost:8080/api/compa

java - 使用 Files.copy() 选择文件名

我在/tmp中有一个临时文件,我想将其存档,所以我尝试了:importjava.nio.file.Files;[...]Pathsource=Paths.get("/tmp/path/to/file_123456789.xml");Pathdestination=Paths.get("/path/to/archive/dir/file.xml");Files.copy(source,destination).失败是因为:/path/to/archive/dir/file.xmlisnotadirectory我知道了!但我只想选择目标文件的名称。到目前为止,我有一些不满意的解决方案:使用

java - 如何在附加条件下使用 Spring Data JPA 示例匹配器

我正在尝试使用SpringJPA的示例来进行搜索。有了下面的代码,大部分都符合要求。publicPagefindShops(Shopcondition,Pageablepageable){ExampleMatchermatcher=ExampleMatcher.matching().withStringMatcher(StringMatcher.CONTAINING).withIgnoreCase();returnshopDao.findAll(Example.of(condition,matcher),pageable);}此外,我只需要状态不等于DELETED的SHOP。比如,.w

java - JPA事务回滚重试和恢复: merging entity with auto-incremented @Version

我想在交易失败后恢复。现在,当然,在任何回滚之后,所有实体都会分离并且实体管理器会关闭。但是,UI仍然保留分离的实体。显然我们不能就这样丢弃用户的更改,所以我们想让他们重试(修复突出显示的验证错误,然后再次单击按钮)。在JavaPersistenceWikiBook之后,OnemethodoferrorhandlingistocallmergeforeachmanagedobjectafterthecommitfailsintoanewEntityManager,thentrytocommitthenewEntityManager.Oneissuemaybethatanyidsthat

java - Spring Data Jpa - 扫描测试文件夹中的文件

我正在使用SpringDataJPA,这很奇怪,但它会尝试扫描(在部署期间)测试文件,这会导致错误:java.lang.ClassNotFoundException:org.junit.runner.RunWithatorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)atorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)...WARN:org.springf

java - 按类类型加载数据的通用 Spring Data JPA 存储库实现

我正在使用SpringDataJPA1.4.3.RELEASE和Hibernate4.2.7.Final我能够成功地创建一个BaseRepository类,类似于:http://docs.spring.io/spring-data/jpa/docs/1.4.2.RELEASE/reference/html/repositories.html#repositories.custom-behaviour-for-all-repositories@NoRepositoryBeanpublicinterfaceBaseRepositoryextendsJpaRepository@NoRepos

java - 使用 Spring Data Rest 在集合上公开超媒体链接,即使它是空的

首先我阅读了上一个问题:ExposinglinkoncollectionentityinspringdataREST但问题依然存在,没有任何技巧。事实上,如果我想公开一个集合资源的链接,我正在使用以下代码:@ComponentpublicclassFooProcessorimplementsResourceProcessor>>{privatefinalFooLinksfooLinks;@InjectpublicFooProcessor(FooLinksfooLinks){this.FooLinks=fooLinks;}@OverridepublicPagedResources>pro

java - Spring Data,JPA @ManyToOne 延迟初始化不起作用

我知道有很多关于这个问题的类似问题,但对我没有任何帮助。我在Aim和User之间有@ManyToOne关系。@ManyToOne(fetch=FetchType.LAZY,optional=false)@JoinColumn(name="user_id",nullable=false,updatable=false)privateUseruser;和@OneToMany(fetch=FetchType.LAZY,mappedBy="user")privateCollectionuserAims;分别。@Override@Transactional(propagation=Propaga

java - 如何在 spring data rest/HATEOAS 中创建一个引用已经存在的子实体的新父实体

在我的项目中,我有两个领域模型。父实体和子实体。父引用子实体列表。(例如Post和Comments)两个实体都有它们的spring数据JPACrudRepository公开为@RepositoryRestResource的接口(interface)HTTPGET和PUT操作工作正常,并返回这些模型的良好HATEOS表示。现在我需要一个特殊的REST端点“创建一个引用一个或多个已存在子实体的新父级”。我想将对child的引用作为我在请求正文中传递的文本/uri列表发布,如下所示:POSThttp://localhost:8080/api/v1/createNewParentHEADERC

java - DMatrixRMaj : get data in matrix form

当我在ejml(实矩阵的标准格式)中初始化一个新的DMatrixRMaj时,它可以在内部存储一个double[][]矩阵。示例double[][]a=newdouble[][];//initaDMatrixRMajd=newDMatrixRMaj(a);//mathoperationsond现在,经过必要的计算后,我如何才能得到d的double[][]形式?使用d.getData()我只能获取行形式。我也试过用SimpleMatrix包装,或从double创建SimpleMatrix,但我没有找到任何方法(或矩阵格式)来检索double!你知道我该怎么做吗?或者您可以提出一个无需编写个