@remmeier I have the below 2 resouces where Project has relationship with Task ``` @JsonApiResource(type = "project")
public class Project {
@JsonApiRelation(mappedBy="project")
private Task task;
...
}
@JsonApiResource(type = "task")
public class Task {
@JsonApiRelation
private Project project;
...
}
``` I am doing a PATCH as /api/project/{id}/task and I get an exception as io.crnk.core.exception.BadRequestException: project/{id}/ResourceFieldImpl[resourceClass=com.example.Project, name=task,resourceType=project] with method PATCH
Can anyone throw a hint why "detached entity passed to persist" is happening?
I have single model without any relationships and both public interface ReportRepository extends CrudRepository<Report, Long>
and public class ReportRepositoryImpl extends JpaEntityRepositoryBase<Report, Long>
repositories.
When creating and updating Report model like this in my tests:
```var report = new Report();
report.setStatus("foo");
reportRepository.save(report);
report.setStatus("bar");
reportRepository.save(report);
```
detached entity passed to persist: com.rimi.socialcards.models.Report; nested exception is org.hibernate.PersistentObjectException: detached entity passed to persist: com.rimi.socialcards.models.Report
happens.
From trace I see that while I'm using ReportRepository, it's somehow calls io.crnk.data.jpa.JpaEntityRepositoryBase.save
.
Why it's that?
ReportRepositoryImpl
class, there is no error with that simple save. That's why I asked question why there is io.crnk.data.jpa.JpaEntityRepositoryBase.save
in trace if I'm using ReportRepository
which extends org.springframework.data.repository.CrudRepository
, not crnk.
I noticed an issue with trying to patch a resource with nested attributes when trying to deliberately null one of the nested attributes to make it empty. It looks like that when crnk's ResourcePatchController has done its thing and the resource arrives to the repository's save method, crnk has initialised the to-be-nulled attribute with the current value from the database. There's no way to determine if it should be nulled anymore in that stage. The intent of emptying the attribute got lost.
I wonder if there would be any solutions for this? Something to declare or make differently in the nested attribute class definition for example? I already took a shot to JsonApiEmbeddable annotation but that didn't seem to affect the behaviour. Didn't really look what it does, though.
All tips and tricks appreciated!
relationships
can only have two links, one for self and the other is related
, can we add custom link to it? but it appears impossible since the code in class io.crnk.core.engine.internal.document.mapper.ResourceMapper.java
hardcode only self and related links as you see below, so not able to add custom link to it, just want to double check with you:
I am using spring-boot-starter-parent version 2.6.4 with Reactive WebClient.
Below are the dependencies.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId></dependency>
I need to use @EnableWebFluxSecurity along with WebClientReactiveClientCredentialsTokenResponseClient from Spring security 5.6.2 version.
I have created a simple REST controller which uses client credentials grant type and integrates with the vendor with Bearer access token through WebClient. When I integrate with the service @GetMapping("/greeting"), the Oauth2 integration with Bearer access token works.
However when I call the CRNK resource url (http://localhost:8080/myResource/someId) I always get 404.
@EnableWebFluxSecurity
@Configuration
@Order(SecurityProperties.BASIC_AUTH_ORDER - 1)
public class SecurityConfig {
@Bean
SecurityWebFilterChain apiHttpSecurity(ServerHttpSecurity http) {
http.cors() .and().authorizeExchange().pathMatchers(“/greeting/**”,“/myResource/**”).permitAll()
.anyExchange().denyAll()
.and().csrf().disable();
return http.build();
}
}
guys I am trying to build the sources from master, when doing gradlew build I get this error:
A problem occurred evaluating root project 'crnk-framework'.
> Receiver class org.ajoberstar.grgit.operation.OpenOp does not define or inherit an implementation of the resolved method abstract setProperty(Ljava/lang/String;Ljava/lang/Object;)V of interface groovy.lang.GroovyObject.
Any ideaS?
Hi everybody. I am currently implementing a board game backend which has game and player resources. Now I would like a mechanisme to send a move to a game so it can validate and execute the move on the game resource. I don't need to store the moves so a move resource seems over kill. In the docs I've found the following possibility:
A dedicated AddressChangeResource that is in a relationship with the person resource. Then a POST request to /api/addressChange or /api/person/{id}/addressChange (depending on the setup) will trigger a new address change. This is the most elaborate setup and can complement the address relationship from before. It allows not just to trigger a change, but also, for example, to query the current status and get a history of changes. This in turn allows to model more complex workflows where an address change may take a larger mount of time and may involve further manual steps.
But how does this work? Is there a code example of this somewhere?