This week's book giveaway is in the Go forum.
We're giving away four copies of Head First Go and have Jay McGavren on-line!
See this thread for details.
Win a copy of Head First Go this week in the Go forum!
  • 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

hibernate : OOD for text base elements  RSS feed

Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
Posts: 24199
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!