How to i write relationships to bellow three entity's?

Multi tool use
Multi tool use


How to i write relationships to bellow three entity's?



If Suppose we have three entity's
entity UserProfile { firstname String
lastname String
}
For the above entity primary key will generate automatically, same as we have another entity
entity SomeTest {
unittest String
}
entity Work{
correction String
}



For the above entity's primary key will generate automatically, So now in user profile entity we have two user records one is student and another one is teacher, in Some Test entity we have one test record that record have key ,so now how can i create relation to add user profile( student nd teacher primary keys) and Some Test Primary key to Work entity.
Please can u write me the relationship to add userprofile & SomeTest Entity primary keys to Work Entity? ans like (relationship OneToMany{}) and what relation it will be and why?





Are you just talking about wanting to add a foreign key to an entity in EF?
– Wurd
May 31 at 10:32





difficult to understand what you are trying to do here. It's better if you can provide your use case in plain english. Accordingly we can help you to create your domain model
– naren
May 31 at 10:41





hi Narender Singh...
– ChaitanyaChowdary Divi
May 31 at 10:47





If we have 3 entity's one is take an example first entity is
– ChaitanyaChowdary Divi
May 31 at 10:48





If u have 3 entity's one is take an example first entity is entity UserProfile { firstname String, lastname String usertype Boolean } (usertype either student or teacher) and second one is entity UnitTest { test1 String } and third one is... entity WorkOrder { revision String }..now my question is how to create relationship in jhipster to add Userprofile id's(Both Teacher and student primary id's) and UnitTest id into WorkOrder.Do you know the jhipster management relationships.I need to create the relation like that.How u can create? do u understand?
– ChaitanyaChowdary Divi
May 31 at 10:57




1 Answer
1



Hello @ChaitanyaChowdary Divi,



As per i understood, your flow is like this,



UserProfile( userid(pk) )
UnitTest( testid(pk) )
WorkOrder( userid(fk-One to Many), testid(fk-One to One) )



Right!!!



If it is right then you should follow this way,



Jhipster provide three way to generate relationship.



Case 1 : Uni-Directional Relationship


relationship ManyToOne {
WorkOrder{userid} to UserProfile
}



Note : If you use OneToMany(reverse order) it is compalsary to define field name of parent table.


relationship OneToOne {
UnitTest{testid} to UserProfile{testid}
}



Case 2 : Add using Terminal - command line


yo jhipster:entity entityName



Case 3 : Manually add in coding,



@OneToOne(mappedBy = "UnitTest")



@JsonIgnore



private UnitTest unitTest;



Add column block in XML file.



Resource -> config -> liquibase -> changelog -> entity.xml


<changeSet id="add specialization column" author="jhipster">
<addColumn tableName="specialization">
<column name="specialization_id" type="bigint">
<constraints nullable="false"></constraints>
</column>
</addColumn>
</changeSet>



Apply this changes in JSON file also.



/.jhipster/entity.json
{
"relationshipType": "many-to-one",
"relationshipName": "specialization",
"otherEntityName": "specialization",
"otherEntityField": "id"
},






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

H uFMr2SJE,UFxuxUhDcTELoxai0FJyiCSn,2h9rBzxYZv,udG,hm 9iDZod4FK,a
C3 2v 5msMmp ySSYib,SJDRjUZOW5uaZnRwWp,tdr5EndJ8j4Jni6iTLzk1Nn rwAnsa

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications