Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19522
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2012-10-26 14:51 -0700 |
| References | <23786bb4-22cc-4711-a172-8e5c7ce5375e@googlegroups.com> <k6etkf$ufg$1@dont-email.me> |
| Message-ID | <7ae71496-be19-497a-b856-7333d3b4adf7@googlegroups.com> (permalink) |
| Subject | Re: How to store and represent 1 objects relationship to other objects |
| From | Lew <lewbloch@gmail.com> |
Daniele Futtorovic wrote:
> pat.trainor@ allegedly wrote:
>> In other words and this maybe a database question, 1 of many
>> thousands of objects is related to any number of other objects. The
>> problem is how to represent or index those relationships each 1 being
>> perhaps either a parent, a child, or a peer of 1 or more thousands of
>> objects.
>
> I have trouble understanding your question, especially why you pose it
> in such an abstract manner.
>
> It's your data you're talking about, right? Well, then you'd better know
If so, then that's bad. They should be talking about their object model.
> darn well how they're related. Once you have established what those
> relationships are, you map them. There ain't many candidates. You've got
> many-to-one, one-to-many, unidirectional one-to-one and bidirectional
> one-to-one relationships. That's about it.
>
> Your starting point must be to analyse what you're modelling, methinks.
Yes, from an object-modeling standpoint.
A common mistake with JPA is to use it as a glorified JDBC, with a data-centric
approach. Its purpose is to provide an object-centric approach that maps to a
data store, not to replace relational modeling or even represent it.
So first question to analyze while modeling: what entities relate to what entities?
How do you model that relationship?
For example, if a retail order system models than an "Order" has multiple "Line Items"
for which reproducible order matters, you likely would have an object model that includes
public class Order
{
List<LineItem> lineItems;
...
}
If you further wish to guarantee that no 'LineItem' appears more than once, you'd likely use a 'Set'
instead of a 'List'. Unfortunately the JPA spec doesn't seem to allow 'SortedSet', but it seems that
the '@OrderBy' annotation hacks around that limitation.
--
Lew
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to store and represent 1 objects relationship to other objects pat.trainor@gmail.com - 2012-10-26 11:40 -0700
Re: How to store and represent 1 objects relationship to other objects Lew <lewbloch@gmail.com> - 2012-10-26 12:23 -0700
Re: How to store and represent 1 objects relationship to other objects Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-10-26 22:59 +0200
Re: How to store and represent 1 objects relationship to other objects Lew <lewbloch@gmail.com> - 2012-10-26 14:51 -0700
Re: How to store and represent 1 objects relationship to other objects Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-10-27 00:48 +0200
Re: How to store and represent 1 objects relationship to other objects Lew <lewbloch@gmail.com> - 2012-10-26 16:07 -0700
Re: How to store and represent 1 objects relationship to other objects Gene Wirchenko <genew@ocis.net> - 2012-10-28 20:47 -0700
Re: How to store and represent 1 objects relationship to other objects David Lamb <dalamb@cs.queensu.ca> - 2012-10-29 10:12 -0400
csiph-web