spring-data

Hibernate: How to ensure that a parent is not deleted when all its child entities are?

为君一笑 提交于 2020-01-11 13:09:10
问题 I am deleting entities and hence rows from my database. I do want to delete a certain entity and all of its child rows. However, I do not want to delete any rows from its Parent . How can I accomplish this? Kennel is the Parent Entity and Dog is the entity I am deleting. Please see code below to how I have linked the 2 in the Kennel Entity: @OneToMany(cascade = CascadeType.MERGE, orphanRemoval = false) @JoinColumn(name = "KENNEL_ID", referencedColumnName = "ID", updatable = true, insertable =

Hibernate: How to ensure that a parent is not deleted when all its child entities are?

淺唱寂寞╮ 提交于 2020-01-11 13:07:06
问题 I am deleting entities and hence rows from my database. I do want to delete a certain entity and all of its child rows. However, I do not want to delete any rows from its Parent . How can I accomplish this? Kennel is the Parent Entity and Dog is the entity I am deleting. Please see code below to how I have linked the 2 in the Kennel Entity: @OneToMany(cascade = CascadeType.MERGE, orphanRemoval = false) @JoinColumn(name = "KENNEL_ID", referencedColumnName = "ID", updatable = true, insertable =

Spring Data Mongo seems to ignore host in XML configuration

烂漫一生 提交于 2020-01-11 06:20:17
问题 I am trying to get a simple "Hello World" program with Spring-Data and MongoDB up and running. Spring seems to be ignoring the MongoDB host IP address configured in the <mongo:mongo/> element and trying to connect to 127.0.0.1 instead. As per various tutorials, here is my Spring Configuration XML: <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mongo="http://www

Why is DELETE not supported on to-many-association resources in Spring Data REST?

China☆狼群 提交于 2020-01-10 20:15:12
问题 I am using Spring Data REST. I am trying to unbind a collection association from an entity (item). i.e. - a property of the item is of List type. I want to remove all items from that List . To do this, I am using the DELETE method: curl -X DELETE …/categories/54ea0bcf27a2fb1b4641083a/fixedParentCategories This gives me a 405 Method not allowed error code. But, it works for a single valued association (when it is not of List type). The documentation clearly lists DELETE as a supported method

Why is DELETE not supported on to-many-association resources in Spring Data REST?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-10 20:15:06
问题 I am using Spring Data REST. I am trying to unbind a collection association from an entity (item). i.e. - a property of the item is of List type. I want to remove all items from that List . To do this, I am using the DELETE method: curl -X DELETE …/categories/54ea0bcf27a2fb1b4641083a/fixedParentCategories This gives me a 405 Method not allowed error code. But, it works for a single valued association (when it is not of List type). The documentation clearly lists DELETE as a supported method

Is it possible to combine MyBatis and QueryDSL/jOOQ?

て烟熏妆下的殇ゞ 提交于 2020-01-10 16:17:54
问题 MyBatis provides the mapping, local cache, and logging out of the box. QueryDSL / jOOQ provide compile-time check of SQL statements and IDE auto-completion as a result. Is it possible to combine them? In other words, I would like to create a query with either QueryDSL or jOOQ, and then execute it with some glue code/adapters with MyBatis . What I have already checked: I considered to generate SQL query strings with QueryDSL and use them in MyBatis with its '@SelectProvider' annotation, but it

Spring Custom Query with pageable

≡放荡痞女 提交于 2020-01-10 14:13:07
问题 I want to to implement pagination in spring application.I know using repository we can implement pagination but we can not write our own query for data retrieve there are limited methods in repository that too there is no method accepting query class. If we want to write our custom query to retrieve data from mongodb we have to use mongotemaplete, as i know with mongotemplate we can not implement pagination. Is there any another way to implement pagination along with db queries. any one can

@Transient annotation, @org.springframework.data.annotation.Transient annotation, transient keyword and password storing

北城以北 提交于 2020-01-10 10:13:25
问题 Currently I'm learning the Spring framework, mainly focusing on it's Security Module. I've watched some guides in connection with registration and login. I saw this common usage of transient keyword or @Transient annotation on the password field in the User class. My dummy app is using Spring Boot + Spring MVC + Spring Security + MySQL. I know that Java's transient keyword is used to denote that a field is not to be serialized. JPA's @Transient annotation ... ...specifies that the property or

@Transient annotation, @org.springframework.data.annotation.Transient annotation, transient keyword and password storing

北慕城南 提交于 2020-01-10 10:13:09
问题 Currently I'm learning the Spring framework, mainly focusing on it's Security Module. I've watched some guides in connection with registration and login. I saw this common usage of transient keyword or @Transient annotation on the password field in the User class. My dummy app is using Spring Boot + Spring MVC + Spring Security + MySQL. I know that Java's transient keyword is used to denote that a field is not to be serialized. JPA's @Transient annotation ... ...specifies that the property or

How to cache results of a Spring Data JPA query method without using query cache?

纵饮孤独 提交于 2020-01-10 06:44:27
问题 I have a Spring Boot app with Spring Data JPA (hibernate backend) repository classes. I've added a couple custom finder methods, some with specific @Query annotation to tell it how to get the data. I have already set up EhCache for the hibernate 2nd level cache, but so far, the only way I can get these results caching is to enable the hibernate query cache. I'd prefer to define a specific cache and store the actual domain objects there just as if it were a normal finder. Below is my repo code