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


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

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

Newsgroups comp.lang.java.programmer
Date 2012-10-26 12:23 -0700
References <23786bb4-22cc-4711-a172-8e5c7ce5375e@googlegroups.com>
Message-ID <f0ba86d3-5450-4049-a7bb-4c670af58940@googlegroups.com> (permalink)
Subject Re: How to store and represent 1 objects relationship to other objects
From Lew <lewbloch@gmail.com>

Show all headers | View raw


On Friday, October 26, 2012 11:40:51 AM UTC-7, pat.t...@gmail.com 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 fully realize that this might in fact be a database question, so forgive me if this ends up being so.
> Because I use Hibernate and JPA I simply consider this a Java question with persistent simply being
> the implementation of how to Java objects are designed.

If you use JPA, presumably you have access to JPA docs, which explain how this is handled.
http://docs.oracle.com/javaee/6/tutorial/doc/bnbpy.html
et seq.

Take note of the annotations '@OneToOne', '@OneToMany', '@ManyToMany' and '@ManyToOne'.
http://docs.oracle.com/javaee/6/tutorial/doc/bnbqa.html#bnbqh

A quick search for "Java JPA" turned this up:
http://www.oracle.com/technetwork/articles/javaee/figure6-137029.html

In fact, I bet you could find all sorts of answers to your questions with a bit of a search:
http://lmgtfy.com/?q=Java+JPA+relationships

What do you mean by "peer", incidentally?

How would you model relationships between entities in your code if there were no database?

Really, this is the question. JPA is for persistence of an object model, not for coding a 
relational model.

When you say, "Hibernate and JPA", I will presume you mean "Hibernate as JPA". There is no 
better way to use Hibernate.

-- 
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