[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - doubts mapping serveral relations

ByDcc do-not-reply at jboss.com
Sun Nov 11 14:04:54 EST 2007


   Hi all,
   I am having problems mapping two relations among tables.
   I am using EJB3, so standard java persistence.

1) First relation definition.
   The idea here is that a category may belongs to many categories. A many
to many relation but with itself.

CATEGORY
  | * ID
  | * DESCRIPTION
  | * more properties
  | 
  | PARENT_CATEGORY
  | * CATEGORY_ID (FK) (foraign with id in table category)
  | * PARENT_ID (FK) (foraign with id in table category)
  | no more properties


2) Second relation definition.
   It is a simple many to many relation between CATEGORY and LOCALE but
the table CATEGORY_LOCALE has more properties. Mayby I might write a
CategoryLocaleEntity with a composite primary key but this composite
key should be a composition of id in CATEGORY and id in LOCALE. 

CATEGORY
  | * ID
  | * DESCRIPTION
  | * more properties
  | 
  | LOCALE
  | * ID
  | * more properties
  | 
  | CATEGORY_LOCALE
  | * category_id (FK) (foraign with id in table category)
  | * locale_id (FK) (foraign with id in table locale)
  | * more properties

   Thank you in advance.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4103503#4103503

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4103503



More information about the jboss-user mailing list