Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jun 26 2017 20:07
    @remmeier banned @hibaymj
almir1982
@almir1982
image.png
Doesn't work because I included 3rd level resource and I get only 1st level resource:
image.png
Removed fields to see will I get 2nd and 3rd level resource and it works. Just for the note I didn't restart component (problem with Hibernate and sequence):
image.png
@remmeier can i put all this that I notice maybe on official site as bugs to not do it here on forum??? So I don't pollute forum with these.
Remo
@remmeier
@ehdrbs0318 that is default JSON:API response. You seem to be interested more in http://www.crnk.io/releases/stable/documentation/#_plain_json. That will get you what you desire. It has the benefit of being simpler, which works well for many use cases. Whereas pure JSON:API allows to do one or the other more powerful thing with complex object graphs.
@jmescheder you can register the NumberSizePagingBehavior by creating it as regular spring bean: @Bean public NumberSizePagingBehavior..... And for input of to the documentation, please create a ticket. Personally I always used offset/limit so far. So I cannot judge.
Remo
@remmeier
@almir1982 yes, a ticket would be very good. Because also a lot of things are going on in other areas and my personal memory also has some limits... :-)
Remo
@remmeier
@almir1982 DocumentMapperUtils.getRequestedFields as of yet does not combine inclusions and field sets. The specification is silent about it https://jsonapi.org/format/#fetching-sparse-fieldsets
in json:api terms both an attribute and a relationship is a field, so it counts for both
@almir1982 did not manage to follow with the request context thing
Percy Hatcherson
@primitive-type
In the context of Spring Boot, how can I run Crnk with no datasource? In other words, I want to run Crnk with the Spring Boot datasource disabled via excludes, so I can run tests which don't need any datasource without having to connect to one
Crnk seems to have many dependencies on a datasource, but I just want to do something like https://stackoverflow.com/a/43991488 or https://stackoverflow.com/a/38150900 when running a particular Spring Boot profile (e.g., @Profile("test")) and not have Crnk yell at me for missing dependencies
for my tests, I am basically just using InMemoryResourceRepository and some @JsonApiResource annotated resource models (the non-test profile part of my application uses JpaEntityRepositoryBase for its repositories, but I don't need access to those at all during tests)
Remo
@remmeier
crnk in general works well without a datasource. One can make use of any kind of repository implementation, not just JPA. You have a concrete exception? I could image that CrnkJpaAutoConfiguration may need a further condition to disable itself. But there is also a property to achieve this.
KrasimirProdanov
@KrasimirProdanov

Hello, did someone know reason for this line
https://github.com/crnk-project/crnk-framework/blob/master/crnk-core/src/main/java/io/crnk/core/repository/foward/strategy/ForwardingStrategyContext.java#L52

Seems that broke calling relationships like url/apartment/1/owner because QuerySpec will have &fields[house]=id
which on first request will prevent apartment to obtain information his owner (because fields like owner/ownerId will be never populated, only populated field will be id)

class House {
  private UUID id;
}


class Apartment {

  private UUID id;

  @JsonApiRelation(lookUp = LookupIncludeBehavior.AUTOMATICALLY_ALWAYS)
  private House owner;

  @JsonApiRelationId
  private String ownerId;
}
Percy Hatcherson
@primitive-type

@remmeier it fails to load the application context, saying

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'crnkBoot' defined in class path resource [io/crnk/spring/setup/boot/core/CrnkCoreAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.crnk.core.boot.CrnkBoot]: Factory method 'crnkBoot' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'io.crnk.spring.setup.boot.jpa.CrnkJpaAutoConfiguration': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'javax.persistence.EntityManagerFactory' available

this happens when I have the following in my application.properties:
spring.autoconfigure.exclude[0]=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
spring.autoconfigure.exclude[1]=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
spring.autoconfigure.exclude[2]=org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
spring.autoconfigure.exclude[3]=org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
Percy Hatcherson
@primitive-type
@remmeier UPDATE: here's what I think my issue was: I had some missing JsonApiId annotations. In the non-test profile, the JpaEntityRepositoryBase class masked the need for the @JsonApiId annotation since it was picking things up based on the standard JPA annotations. Once I was no longer using the JpaEntityRepositoryBase for tests, though, and switched to the InMemoryResourceRepository class, Crnk was looking for the primary keys of the resources with the missing @JsonApiId annotations and couldn't find them.
Remo
@remmeier
@primitive-type I guess you disabled crnk.jpa.enabled to make it work? Yes, the JpaModule provides some functionality to also understand JPA annotations next to JSONAPI ones. Could be added without the JPAModule if desired.
Remo
@remmeier
@almir1982 I did a quick check for mixing include=...&field=..., but could not reproduce an issue. There is DocumentMapperUtil.computeRequestedField which honors both includes and fields to determine what should be returned to the client.
@KrasimirProdanov both the relationship is requested with an inclusion and the id as field. then should all be fine? but it might be related to what @almir1982 mentioned.
@almir1982 maybe a test case in crnk-example or crnk itself would be great if you manage to reproduce it outside your project
Remo
@remmeier
(see BasicRepositoryAccessTestBase for the recent additions)
Percy Hatcherson
@primitive-type
@remmeier yes I forgot to mention I toggled crnk.jpa.enabled to false in the test profile
Remo
@remmeier
yes, makes sense. JpaResourceInformationProvider is the one registerd by the JpaModule to read JPA annotations.
almir1982
@almir1982
@remmeier as i previously mentioned it's not problem to have this call:
http://localhost:8111/v1/crm/profile/20-1002637/?fields=accountName&include=profileContacts,profileAddresses but when you request also 3rd level:
http://localhost:8111/v1/crm/profile/20-1002637/?fields=accountName&include=profileContacts.contact,profileAddresses.address problem happens that he then returns only profile in my case :(. Will try to see what happens in this mentioned class. Any info about count to be controlled as property and maintaining ordering when creating map for hibernate issue with 3rd level?
almir1982
@almir1982
@remmeier maybe issue is in this line of code because when you get 2nd level it works.
image.png
But when I include 3rd level to return address i get this here (its part of code that handles relationships where realation=true).
image.png
As you can see on following picture i didn't get profile-address at all but I did get profile-contact (2nd level). So maybe you should send full list here also?
image.png
KrasimirProdanov
@KrasimirProdanov
@almir1982 about my problem can you try to add in GET request ?fields[{{RESOURCE_TYPE]={{ID_NAME}} and tell me if you get only that field back
almir1982
@almir1982
@KrasimirProdanov did you mean something like this??
image.png
KrasimirProdanov
@KrasimirProdanov
And should be just this field problem happen when we got
Service_1 call Service_2 to get relationship I mention above
What will happen is CRNK will make request first to find the Apartment and then will use ownerId field to make second request to find the House but because Apartment request was include only his id .. ownerId is null then request for find House -> id will be QuerySpec with id=null
@almir1982 yes
That is the reason after updating from CRNK 2.10 to 2.11 my request to not work anymore
almir1982
@almir1982
@KrasimirProdanov but to me same problem still remains that 2nd and 3rd level were not mapped even if sql query was properly executed (when i requested also 3rd level) but if i only requested 2nd level it would work and everything is returned okay.
Remo
@remmeier
@almir1982 can you create a ticket?
just to focus the discussion at one place
almir1982
@almir1982
@remmeier created 3 tickets: 1)Issue with 3rd level working and then not working 2) Issue with using include and 3rd level in filter 3) Count to be property and maybe to have control over filter parameter (would be great :)). Ticket id's are: 650, 651 and 652.
Sebastian Wyrazik
@swyrazik

Hello. Thanks for building this framework, it's full of useful features. :)

I need some advice/guidance on the following situation:
Is there a way to register resources (and repositories) using an arbitrary set of classes that represent resources but are simple POJOs that don't make use of any annotations?

I guess this is an uncommon use case, as most examples depend on the use of some kind of annotations, be it Crnk, Jackson, or JPA annotations. The documentation section I found most relevant for this use case is 16.10. Create repositories at runtime, but I'm not sure if this would be the best path to take or if there is a different, more appropriate approach.

The reason we (my team) need this is that we have to register resources based on POJOs that should neither depend on any 3rd-party dependencies nor be aware that they will be registered as resources. We need to do this primarily for the client-side if that matters.

I hope it's clear.

Remo
@remmeier
@swyrazik repositories have to implement the ResourceRepository interface. But how this looks like is entirely up to you. A repository for every resource or a single repository for many resources are equally well possible. That repository could be an adapter to the underlying untouched implementation. If you don't want to use annotations, then yes, repositories at runtime would be the way to go.
Remo
@remmeier
@almir1982 thx, lets move the discussion there. I checked the test cases that worked all fine, but spotted some differences where I'm not sure where they are coming from.
@KrasimirProdanov can you also check with a current crnk 3.x version? version 2.10 and 2.11 are more than a year old. So there is a good chance you miss one or the other improvement. Or maybe also create a ticket with the details. What I can say for sure is that relationship handling got quite some upgrades the past 1 1/2 year. Especially also in the JPA area. So it is currently hard to judge whether the issue still persists.
Percy Hatcherson
@primitive-type
Is there an example anywhere of extending DefaultQuerySpecUrlMapper to implement custom behavior for a specific FilterOperator on a specific field on a resource? In particular, I just want to implement custom behavior for gt and lt filter operators for one field on one resource. I want to call out to a custom class's method for the comparison