• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Two identical entities with similar attributes.

 
Ranch Hand
Posts: 227
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I heard a technical scenario where 2 entities having same attributes. A Boy and Girl Entity with Name, Age and DOB. How this can be formed as single entity so that fields are not repetitive ? Please share any idea. I'm also keen to find the right solution through studies. But your ideas may also help. Thanks.

Regards,
Mohammed Sardar
 
Saloon Keeper
Posts: 10764
229
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ehh, how about a 'person' entity with a 'gender' field?
 
Mohammed Sardar.
Ranch Hand
Posts: 227
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Ehh, how about a 'person' entity with a 'gender' field?


Thanks, so "Gender" as @Embedded you mean ? Can you elaborate please ?
 
Stephan van Hulst
Saloon Keeper
Posts: 10764
229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think that Gender would be so complex to warrant an embeddable type. Just use an enum for Gender and you can annotate the gender field with @Enumerated in your Person entity.
 
Mohammed Sardar.
Ranch Hand
Posts: 227
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:I don't think that Gender would be so complex to warrant an embeddable type. Just use an enum for Gender and you can annotate the gender field with @Enumerated in your Person entity.


Stephan, by your idea what I understand is change to the db design of table structure itself. Instead having two tables (Boy and Girl) have one table with the name PERSON with attributes(NAME, AGE, DOB, GENDER(ENUM)) and represent the above Person table as a single Entity. Am I on track to get the above ?

Thanks & Regards.
 
Stephan van Hulst
Saloon Keeper
Posts: 10764
229
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, although I don't know why you would want to have an age field if you already have a date of birth field.
 
Mohammed Sardar.
Ranch Hand
Posts: 227
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Yes, although I don't know why you would want to have an age field if you already have a date of birth field.



True, may be Edit button was disabled !!!
 
Beauty is in the eye of the tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!