我有一个实体A,它有一些属性,并且引用了另一个实体B
A{
....
@ManyToOne(fetch=FetchType.LAZY)
B b;
...
}
B也是如此(@onetomany for A in B)。这是一种双向关系。当为实体A调用web服务时,它在响应json中提供到B实体的链接,而不是整个对象。我希望整个对象在web服务响应JSON中,而不是链接到相关实体。我该怎么做呢?我使用了springboot + spring data jpa + hibernate作为jpa提供者+ spring 4
我们有两个具有客户端服务器架构的Spring应用程序。后端配置为Spring数据REST + JPA。前端应该使用后端公开的资源,并提供公共REST。
通过声明(例如,映射bean )可以让Spring数据从DTO自动映射域对象吗?
// JPA persistable
@Entity
public class Order { .. }
// Immutable DTO
public class OrderDto { .. }
// Is this somehow possible..
@RepositoryRestResource
public interface OrderDtoRe
我正在使用Spring Data JPA和Spring Data Rest将我的JPA实体公开为JPA服务。我的实体有几百个属性,oneTo(非常)与其他具有数百个属性的实体有很多关系。
我希望用户能够传递一个查询参数,允许他们只返回他们关心的JSON响应体的字段。在过去,我使用过IBM的Rational Team Concert REST API,它们允许调用者传入XPath查询来选择他们想要返回的字段。它们的XPath集成还允许调用者在各个字段上应用过滤逻辑。例如,以下是使用该API可能实现的功能:
workitem/workItemcreator/name='Bob Sacrem
我在Spring Data JPA中使用Spring Data Rest时遇到了问题。我使用的是Spring-boot 1.4.4.RELEASE。
下面是我的spring-data-rest存储库:
public interface ProfileJpaRepository extends JpaRepository<Profile, Long> {
}
以下是我的实体(为简洁起见,未显示getter和setter)。
Profile.java:
@Entity
@Table(name = "PROFILE")
public class Profile {
我是Redis的新手,正在尝试将Postgres DB更改为Redis DB。当前的实现我们使用了Spring Data JPA (实体类+ JPA存储库)。现在我想在内存DB中使用Spring Data Redis和backend作为Redis。
你能建议我需要在所有实体类中做哪些更改吗?持久化将如何发生?我是否需要在Join表等中进行任何更改。我有@ManyToOne和@ManyToMany的关系。
Spring Data JPA在WebSphere 8.5.5上部署后,删除会导致OutOfMemoryError。但它在部署了Spring Boot连接到同一数据库的Tomcat上运行良好。它试图删除的实体有许多对子实体的双向ManyToOne引用。Oracle 11g数据库上的数据集非常小。对于没有子项的其他实体,删除操作运行良好。我尝试过使用WebSphere和Apache持久性提供程序。我的系统输出显示它停留在一个很长的select语句上,并消耗了所有可用内存。select语句由JPA Hibernate生成。相同的select调用在配置了Spring Boot的Tomcat上运行良好
我正在用Spring Boot,Hibernate和PostgreSQL编写一个REST MVC web应用程序。我需要从我所有的carts中拿出6种最受欢迎的饮料。为此,我首先用SQL编写了一个query SELECT drink_id, sum(count) as count
FROM cart_items
GROUP BY drink_id
ORDER BY 2 DESC
LIMIT 6 有一个结果,下面的代码运行得很好: ? 因为我使用的是JPA-repositories,所以我决定用HQL编写相同的查询。请求是我写的,但我不得不删除LIMIT一段时间,因为我不知道如何在HQL中
这是我的repository接口:
public interface ContentRepository extends JpaRepository<Content, Long> {
@Query(value = "select c from Content c where c.ContentCategory.genre = :genre and c.ContentType.genre = :contentType")
Iterable<Content> findByTypeAndCategory(@Param("conten
我一直试图返回以给定名称开头的城市的基本列表,但没有成功,我尝试了以下所有组合:
在Spring数据中使用纯JPA关键字:
List<City> findByNameENStartingWithIgnoreCaseAndAdminDivisionAndCountry( String cityName, AdministrativeDivision administrativeDivision, Country country);
使用LIKE和CONCAT:
@Query("SELECT c from City c WHERE UPPER(c.nam
我有一个与Oracle数据库应用程序连接的Spring。应用程序的相同版本在MySQL中可以正常工作,但是当我尝试对Oracle执行一些请求时,它会引发错误:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract
我正在尝试让Spring Data JPA使用joins发出一个查询,以便急切地获得实体图:
@Entity
@NamedEntityGraph(name = "PositionKey.all",
attributeNodes = {@NamedAttributeNode("positionKey.account"),
@NamedAttributeNode("positionKey.product")
})
@Data
public class Position {
@EmbeddedId
p
我有一个包含Comment集合的Post实体,如下所示
@Entity
@Table(name = "post")
public class Post {
@Id
private Long id;
@OneToMany(
mappedBy = "post"
)
private List<Comment> comments= new ArrayList<>();
注释实体
Entity
@Table(name = "comment")
public class Comment{
@Id
private Long
我正在开发一个使用Spring Boot,Spring Data JPA和Spring Data Rest技术的web项目。我能够成功地设置一切,并能够获得一个简单的POJO的JSON。我自定义了两个类来实现OneToMany和ManyToOne的关系,如下所示:
@Entity
@Table(name="t_profile")
public class Profile {
@Id
@column(name="profile_id")
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.example.dto.ExampleDto]
at org.springframework.core.convert.support.GenericConve
我目前正在尝试评估使用Spring Data JPA的可能性。
在尝试使用投影时,我目前被困在尝试获取特定属性Trying。
我有一个简单的实体,它用外键引用了另一个实体。现在我想为先前的实体定义不同的预测。“原始”属性可以很好地投射到投影界面中,但尝试投射另一个实体/投影会导致它仍然处于延迟加载状态。
现在我想告诉Spring/JPA在projections中急切地加载实体/投影。一种可能的方法是使用EntityGraphs (它们工作得很好),但我必须使用不同的图为每个方法创建存储库。问题是,还有哪些其他方法?
示例:
实体买家:
@Entity
public class Buyer {
我得到了Spring数据Rest项目的以下异常:
com.fasterxml.jackson.databind.JsonMappingException:
No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer
(to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) )