spring-data-jpa

spring jpa : how to only fetch EmbeddedCollection only

我的未来我决定 提交于 2020-08-10 19:18:45
问题 i have a class which containes an embedded collection @Entity @Table(name = "users") @Data @NoArgsConstructor public class User { @Id @GeneratedValue private long id; @Column(name = "user_name", nullable = false, unique = true) private String userName; @Column(name = "password", nullable = false) private String password; @Column(name = "email") private String email; @ElementCollection @CollectionTable(name = "mobile_numbers_List",joinColumns = @JoinColumn(name = "user_name"

Bean validation on associations not working when using generation strategy IDENTITY

ⅰ亾dé卋堺 提交于 2020-08-10 19:14:04
问题 I have got the following Parent, Child and Subchild entities: @Entity public class Parent { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID", nullable = false, precision = 20) private Long id; @Valid @BatchSize(size = 5) @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent") private List<Child> childs = new ArrayList<>(); ... } @Entity public class Child { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "ID", nullable

Not save inner list of entites

只愿长相守 提交于 2020-08-10 19:12:07
问题 Spring Boot 2.2 Models: @Entity public class Cart { @Id @GeneratedValue(strategy = GenerationType.AUTO) @JsonIgnore private int id; @NotNull private String cartId; @NotNull private String username; @NotNull @DateTimeFormat(pattern = "dd.MM.yyyy HH:mm:ss") private Date created; @DateTimeFormat(pattern = "dd.MM.yyyy HH:mm:ss") private Date updated; @OneToMany(mappedBy = "cart", fetch = FetchType.EAGER, cascade = CascadeType.MERGE, orphanRemoval = true) private Set<ProductEntry> productEntities

How to match a list exactly with all values present in JPA Hibernate?

空扰寡人 提交于 2020-08-09 09:07:44
问题 I have a User entity with skills property as a type List. I want to query the User table against a list of skills in such a way that if all the skills are present in skill column then only a match is found unless no. I have used JPQL for this but it matches each element in the list one by one using the IN clause. User Class @Entity(name = "App_User") //table name "user" is not allowed in postgres public class User { @Id @GeneratedValue(generator = "UUID") @GenericGenerator(name = "UUID",

How to match a list exactly with all values present in JPA Hibernate?

梦想的初衷 提交于 2020-08-09 09:07:16
问题 I have a User entity with skills property as a type List. I want to query the User table against a list of skills in such a way that if all the skills are present in skill column then only a match is found unless no. I have used JPQL for this but it matches each element in the list one by one using the IN clause. User Class @Entity(name = "App_User") //table name "user" is not allowed in postgres public class User { @Id @GeneratedValue(generator = "UUID") @GenericGenerator(name = "UUID",

JPA CriteriaBuilder like on double

℡╲_俬逩灬. 提交于 2020-08-08 18:51:26
问题 I'm trying to retrieve data out of a legacy database. The column in the table is defined as a DECIMAL(13,0) containing account numbers. The column data type cannot be changed as it will have a major impact on the legacy system. Essentially all programs using the table need to be changed and then recompiled which is not an option. We have a requirement to find all records where the account number contains a value, for example the user could search for 12345 and all accounts with an account

JPA CriteriaBuilder like on double

谁都会走 提交于 2020-08-08 18:51:12
问题 I'm trying to retrieve data out of a legacy database. The column in the table is defined as a DECIMAL(13,0) containing account numbers. The column data type cannot be changed as it will have a major impact on the legacy system. Essentially all programs using the table need to be changed and then recompiled which is not an option. We have a requirement to find all records where the account number contains a value, for example the user could search for 12345 and all accounts with an account

Spring boot @DataJpaTest exclude filter doesn't work

有些话、适合烂在心里 提交于 2020-08-08 05:24:47
问题 I Have this test: @RunWith(SpringRunner.class) @DataJpaTest(excludeFilters = @Filter(type = FilterType.REGEX, pattern = "io\\.rainrobot\\.adwisdom\\.repository\\.es\\..*")) public class AskTest { that should not scan repositories in this packege: io.rainrobot.adwisdom.repository.ex.* - but when i run the test i get this error: Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page io.rainrobot.adwisdom.repository

I tired to do something with JpaRepository But Can not find row with findById ,

為{幸葍}努か 提交于 2020-08-07 21:56:50
问题 I have tried to get row by id with findById method but it it not succeed can't find row in DB . and when I call findAll before findById it's work fine. I use PostgreSQL. public void updateOffer(OrderOfferDTO orderOfferDTO) { // List<OrderOfferEntity> all = orderOfferRepository.findAll(); OrderOfferEntity orderOfferEntity = orderOfferRepository.findById(orderOfferDTO.getId()).orElse(null); assert(orderOfferEntity != null); if (!isCanOfferUpdate(orderOfferEntity)) return; orderOfferEntity

I tired to do something with JpaRepository But Can not find row with findById ,

别等时光非礼了梦想. 提交于 2020-08-07 21:56:05
问题 I have tried to get row by id with findById method but it it not succeed can't find row in DB . and when I call findAll before findById it's work fine. I use PostgreSQL. public void updateOffer(OrderOfferDTO orderOfferDTO) { // List<OrderOfferEntity> all = orderOfferRepository.findAll(); OrderOfferEntity orderOfferEntity = orderOfferRepository.findById(orderOfferDTO.getId()).orElse(null); assert(orderOfferEntity != null); if (!isCanOfferUpdate(orderOfferEntity)) return; orderOfferEntity