Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Association problem

 
Danilo Dadonas
Ranch Hand
Posts: 59
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I working in a botton-up project. The database schema is precarious, but I cant�t change because all the system was developed precariously too. The problem is about 2 tables:
--------
Company
--------
id
name
phone
...
--------

-----------
Preferences
-----------
billing_address (FK - Company.id)
shipping_address (FK - Company.id)
...
-----------


I'm creating 2 class:
-----------------------
Company
-----------------------
int id
String name
String phone
Preferences preferences
-----------------------

-----------
Preferences
-----------
Company billingAddress
Company shippingAddress
...
-----------

If, for example, the billingAddress is the same, I'll refer like this:
references.billingAddress = this.
It's the solution I'm thinking about. There is other best way? Can Hibernate support it?

Thanks in advance.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!