Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #19524

Re: How to store and represent 1 objects relationship to other objects

Received by 10.66.75.164 with SMTP id d4mr7006669paw.10.1351292872225; Fri, 26 Oct 2012 16:07:52 -0700 (PDT)
Received by 10.68.223.98 with SMTP id qt2mr7842282pbc.20.1351292872208; Fri, 26 Oct 2012 16:07:52 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!newsfeed.news.ucla.edu!usenet.stanford.edu!kt20no11718107pbb.1!news-out.google.com!6ni32220pbd.1!nntp.google.com!kr7no11962129pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.java.programmer
Date Fri, 26 Oct 2012 16:07:52 -0700 (PDT)
In-Reply-To <k6f40s$5ji$1@dont-email.me>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T
NNTP-Posting-Host 69.28.149.29
References <23786bb4-22cc-4711-a172-8e5c7ce5375e@googlegroups.com> <k6etkf$ufg$1@dont-email.me> <7ae71496-be19-497a-b856-7333d3b4adf7@googlegroups.com> <k6f40s$5ji$1@dont-email.me>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <3834ddac-dd89-4fea-a636-6e29fced82f3@googlegroups.com> (permalink)
Subject Re: How to store and represent 1 objects relationship to other objects
From Lew <lewbloch@gmail.com>
Injection-Date Fri, 26 Oct 2012 23:07:52 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.java.programmer:19524

Show key headers only | View raw


Daniele Futtorovic wrote:
> Lew allegedly wrote:
>> 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.
> 
> My emphasis was on "your" -- in the sense of: something the OP ought to
> be closely acquainted with. His use of the word "objects" could be
> interpreted to mean that the model is already in place. But either way,
> you Lew make a very valid point.

As do you, Daniele. As did Arved in another communication.

Despite what I said, I recognize that JPA can, and sometimes should be used as 
a way to adopt a database model into an object model, rather than simply persist 
the object model. JPA is not intended for overly rococo data models, such as the 
kind where every DBA trick in the book is pulled, but within its intended sphere it is 
very useful to impose an object model atop a data model.

But that doesn't mean one should program the application the same as if they were 
using JDBC. In such a situation, why not use JDBC? The idea is to graft an *object* model 
onto the data, or use the datastore to persist the *object* model, not to write Java code for 
a relational model. That's the reason for having a mapping at all between object and relational 
models, that is, an object-relational mapping (ORM).

JPA is not for writing relational code. That's what JDBC is for.

There's a lot more to JPA than that, of course. In my own experience I've found a very 
effective idiom for JPA, but I'm having trouble articulating it. I've even written code comparing 
a "classic" monolithic Hibernate approach (a giant Session for everything) vs. a "modern" JPA 
approach - tiny data-access helpers each with their own EntityManager, one per service. (Also
used Hibernate for that one.) The tiny-helper approach was much easier to work with and 
understand and optimize, IMO. I've been on a few projects where the monolithic ORM session 
caused huge problems. 

It's the same sort of thing that has Java coders write local object references inside a loop instead 
of longer-lived ones declared outside the loop. The short-lived objects release their resources 
quicker (e.g., don't move to the tenured generation) and are easier to reason about.

-- 
Lew



Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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