JHipster OneToMany relations don't show up in the front-end as lists - spring

So I created a monolith (Spring+Angular) with JHipster 7.8.1 CLI, then proceeded to add 2 entities with the CLI too, I first created Author, then created Book and specified its ManyToOne relation to Author, then modified Author to add the OneToMany relation on the other end (I cannot add ManyToOne while creating Author since it will look for the Book entity which isn't created yet and would therefor raise an error).
The ManyToOne relation works fine on the front-end, I can see the author field in the Book entity, and can select one when editing/creating a book. However on the other hand the OneToMany relation doesn't seem to work, I cannot see the list of books of each author nor edit/add one or multiple books to an author.
Am I doing something wrong or do I need to modify the front-end code to enable this feature?
EDIT: the list of books of an author does fill on the server-side, this can be verified with the Rest API (/api/authors), the books field is returned and has the related books.

Related

Querying polymorphic relation with different deepths in Laravel

I have a Laravel 8 application in which I designed two models, Workspace and Section. Every section belong to a workspace, in a one-to-many relationship.
Both sections and workspaces can have comments; they are implemented in a third model, Comment, with a morphTo relationship. In particular, every comment belongs to a commentable, i.e. a Workspace or a Section.
I'm looking for properly defining a relationship which, from Workspace, allow to retrive all the related comments, i.e. both workspace comments and comments of sections belonging to the workspace.
Can I define somehow this kind of relationship? In particular, I would hypothetically define it a proper way, such that I can use commands like Workspace::with('all_comments') and $workspace->load('all_comments').
Laravel seems not offer a standard interface for defining custom relationships
Thanks,

Laravel Varbox 2.x - duplicate model with relationships included

I’m using the HasDuplicates trait on my Post custom entity.
The Post has 2 relations:
has many comments
has one author
How can I configure the duplicate functionality in order to duplicate a post record along with its relationships: comments and author?
I see in your documentation that I have the option of excluding relations, but not to include them.
The Varbox\Traits\HasDuplicates automatically duplicates all your eloquent model relationships by default, so that's why there's no option to include any relationships to be duplicated, because they all are duplicated by default.
Also, in the event where you don't want certain relations duplicated (such as belongs to relations), you have the option to exclude them (as you already stated): https://varbox.io/docs/2.x/duplicate-records#exclude-relations
So to answer your questions, you don't need to do anything to include your comments and author relations into the duplication functionality, as they will be included by default.
Suggestion: Depending on your database structure and logic architecture, I think you should consider converting the author relation into a belongs to, instead of has one, but that's up to you.

Dynamics 365 OData getting 1:N linked entities

I have entities of type account which when I look at it in Dyn365 it has a section containing a list view of related entities. How do i get these related entities from the OData API?
I can query api/data/v9.1/account but the related entities do not appear anywhere in the resulting json.
If I do the same for the related entities the account do not appear anywhere. How do I get the link between these two types of entities? using the OData API.
I've tried things like /accounts?$expand=contact($select=foo) but it just says contact property do not exist on the account entity, which is correct. But contact is not a property its an entity type.
Solution is to use the following url to get the names of all relationships.
https://<company>.crm.dynamics.com/api/data/v9.1/RelationshipDefinitions?$select=SchemaName
Result is an array of the following rows for each relationship.
{"#odata.type":"#Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata","SchemaName":"aaa_bbb","MetadataId":"<guid>"},
Then use those names, specifically the SchemaName property in the $expand query parameter.
https://crmdev.crm.dynamics.com/api/data/v9.1/accounts?
$select=<whatever>&
$expand=aaa_bbb($select=<properties from linked entity>)
To figure out what relationship actually do what you need, you need to read in more then just the SchemaName if you can't guess what is what, or look it up in Dynamics through the GUI if you know how and have access. I don't.
The RelationshipDefinition contains other properties like ReferencedEntity ReferencingEntity that can be used to determine if you got the right relationship.
Probably, this is what you are looking for. The relationship for 1:N between account and contact is contact_customer_accounts
All accounts with its related contacts:
https://crmdev.crm.dynamics.com/api/data/v9.1/accounts?$select=name&$expand=contact_customer_accounts($select=fullname)
Particular account with related contacts:
https://crmdev.crm.dynamics.com/api/data/v9.1/accounts(73C84814-729B-EA11-A811-000D3A370DB6)?$select=name&$expand=contact_customer_accounts($select=fullname)

Eloquent laravel relationship

I have a project and I want to do it, but I got a problem in relationships.
Project Details:
The system consists of a set of courses, each course offered by one or more trainers, and each trainee can enroll in one or more courses.
My question :
How do I make relationships in Laravel? So that I can get all courses of the trainee with the course information and the trainer who provided the course.
My question : How do I make relationships in Laravel?
Laravel uses eloquent to define models and relationships.
In your case, i think you are looking for a One to Many and Many to Many relationship:
Course has many traniners
Trainee belongs to many courses
Course belongs to many trainees
TIP: In Many to Many relationship is needed a third table with both primary key.
Just look the documentation.
https://laravel.com/docs/master/eloquent-relationships

How to handle a chain of OneToMany relationships in QueryDSL?

Thus far I have referred to this repo as a reference for how to structure my repositories in my Spring project which leverages QueryDSL.
The only "shortcoming" of this example for me is that it does not outline how I might write a Repository which uses a chain of more than one OneToMany relationships. Using this repository as an example/reference, they have a "Customer" repository and for each Customer there are many "Address". I'm unsure how I would use give or take the same patterns they are using, but for a Class which had a OneToMany relationship with Customers. Meaning, how would I handle a Repository for "CustomerGroup" which has a OneToMany relationship with "Customers" which in turn has a one to many relationship with "Addresses".
Some patterns have occurred to me, but not seem elegant/optimal so I'm looking for anyone with experience or insight as to what might be a nice way of solving this problem.
I very much appreciate any help!
Do you mean in order to write WHERE statements based on the relations?
For example if you want to retrieve all customer groups that contain a customer from a specific country, you can simply call
QCustomerGroup.customerGroup.customer.any().addresses.any().country.eq("Germany")
To make this working to need to add
#OneToMany
private Address addresses;
to the Customer entity.

Resources