• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hibernate : OOD for text base elements

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm writing a basic crud app that will be a combination of simple structured data and some narrative text. I'm wondering if the following is a good idea for a design concept, and if it's widely used. Say I have a Widget and a ThngAMaBob class, and each has a description field. would it make sense to encapsulate the text like so:




The markdown text would be the main type that the user would enter and edit. On a save, a markdown parser would create the html text, and a function would create a third text field that would strip out all the html tags, and that  plain text would be used for searching.
The advantage to doing it this way, is that I could search just the TextElement table and return any obj associated with it, as opposed to searching each and every obj that contained a text field.

Is that a design commonly used?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done that for complex text entities which can belong to a variety of objects in my design. For example a Taxon and a TaxonomicUnit and a ChecklistEntry and several other types can all have a Description. There's also an implied requirement that a Description can only belong to one entity.

The downside of that is that it isn't possible to determine what entity a Description belongs to, and I don't think you can use a standard entity-relationship diagram to describe my design. However I'm not using Hibernate or any other ORM system so I haven't had to struggle with them.
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic