Jhipster 2.27.2 : relationship doesn't seem to be well created - jhipster

I am using Jhipster 2.27.2
I have created an entity : collaborateur(nom,prenom)
I have created an entity : societeClient with relationship with collaborateur :
Generating relationships with other entities ? Do you want to add a
relationship to another entity? Yes
? What is the name of the other
entity? collaborateur
? What is the name of the relationship?
collaborateur
? What is the type of the relationship? one-to-many
? What is the name of this relationship in the other entity ?
societeClient
When running mvn I am getting this error :
Caused by: org.hibernate.AnnotationException: mappedBy reference an
unknown target entity property:
com.techvalley.rhtechvalley.domain.Collaborateur.societeClient in
com.techvalley.rhtechvalley.domain.SocieteClient.collaborateurs
societeClient property doesn't exist in Collaborateur class.
Is it normal?

This is the expected behavior: you did not create the societeClient relationship in collaborateur before creating the other entity.
This is documented here: https://jhipster.github.io/managing-relationships/
To fix your entity, you can read 'Generating an entity a second time'
https://jhipster.github.io/creating-an-entity/

Related

Jhipster entity creation is giving error "Cannot read property 'toLowerCase' of undefined"

I want to create multiple entities, and use 1st entity as a dropdown in 2nd
So created first entity with name:
Then I gave it relationship with Jhipster Already created entity User:
Finally:
Now that my entity is created, I am generating second entity and wants to use first entity, as well as user entity to use as dropdown in second entity.
Creating second entity:
Giving relationship with User entity, just like I gave to First Entity:
Giving relationship with FirstEntity:
Failure message:

Liferay 7 : Many-To-Many relationship in service.xml

I want to know if it is possible to have Many to many relationships in service.xml in liferay 7.1.
I have my first entity : Service, that is linked to one or many "Zone" entity. So is it possible to do this in service.xml or i must create a relationship table (but not optimized for search and filter) ?
Thanks for your answers
Regards

In JHipster how to create entity with relationship with User?

I need to create my own entities using the JHipster using the command "yo jhipster:entity myEntity" that have many-to-one relationship with the User entity that comes by default in JHipster.
I have tried unsuccessfully to create in the wizard a relationship with the entity "user" and the field "login" but it is not working.
What is the good way to do this with JHipster? Or do I have to create the entity without JHipster tool (but I need the CRUD!).
Thanks,
Yann
Just an update - jhipster 2.5.0 was released a few days ago adding support for this. Created this answer since the formatting in comments make i pretty hard to read.
When creating a relation for your entity simply answer the questions like this
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? user
? What is the name of the relationship? owner
? What is the type of the relationship? many-to-one
? When you display this relationship with AngularJS, which field from 'user' do you want to use? login
Possible values on how to display the relation could be: id, login, first_name, last_name, email
See https://jhipster.github.io/2015/03/01/jhipster-release-2.5.0.html for moreinformation
Just to add to the correct answer by #stoffer, if you're using the jdl it will look like:
relationship ManyToOne {
Owner{user(email)} to User{owner(name)}
}
at a good sample in an official document is say :
entity Blog {
name String required minlength(3),
handle String required minlength(2)
}
relationship ManyToOne {
Blog{user(login)} to User
}
jdl-samples/blog.jh
If you are using the 1.x version, this wasn't made to work, so basically you should do it by hand, without the generator (but it is definitely doable).
For the 2.x version, we have refactored the User object to have an ID field -> this should make this a lot easier, but as this is not released yet, we don't have a feedback at the moment.
I have come into this issue and solved it by using a simple one-to-one relationship first that will extend the user entity, because it is simple and manageable easily and can make the extended entity be the owner of the relationship, then you can create the many-to-one relationship with your entity, like this example:
entity MyEntity {
MyField Type
...
}
entity ApplicationUser {
additionalField Type
...
}
relationship OneToOne {
ApplicationUser{internalUser} to User
}
relationship ManyToOne {
MyEntity{appUser} to ApplicationUser{myEntities}
}
For more details and approach refer to this jHipster page.

Multiple similar entities or use the same one in core data?

So I've got a Client entity that needs a relationship to a PhoneNumber entity to allow multiple phone numbers. And I've got an Employee entity that also needs a relationship to a PhoneNumber entity to allow multiple phone numbers. Should I create two separate PhoneNumber entities or can I somehow use the same entity for both?
I would create a parent entity called Person for your Client and Employee entities. The Person entity would have a relationship to the PhoneNumber entity.
Inherited entities have the same attributes and relationships as their parent entity. Of course you can add attributes and relationships to the "child"-entities as well. I omitted that in the screenshot.
Something like this:
you can configure the parent entity in the core data inspector in the right side pane.

Core Data automatic migration doesn't create the new entity in my new model

I made a new version of my core data model which includes one new entity "Test" with one attribute "type".
The lightweight migration worked with no errors but I noticed that the new entity was not created in the database. When fetching this new entity "Test" , the result was nil. I had the attribute "type" set as non-optional with a default value of 1 because I expected that the migration will create the new entity with this default value . But it didn't. So my question is : is this expected behavior? In the case of core data migration, the new entities are not created but set as nil? Or if I am missing some steps , what happens if the new model has relationships between the new entity "Test" and the existing entities? Thanks.
You need to create an object of this entity, using for example -[NSEntityDescription insertNewObjectForEntityName:...]. Simply having the entity in the model will not create any objects.
You can do this at the end of migration, or lazily at startup (if you do a fetch for an object of this entity and can't find it).

Resources