-1

I have the following 5 classes [other attributes and methods have been skipped]

CommonInterface.java

    import java.util.Vector;

    public class CommonInterface {

        public Vector  myDescription;
        public Vector  myPartyPlaceThing;
        public Vector  myRole;
        public Vector  myMomentInterval;

    }

Description.java

    import java.util.Vector;

    public class Description {

     public Vector  myPartyPlaceThing;
        public Vector  myCommonInterface;

    }

PartyPlaceThing.java

    import java.util.Vector;

    public class PartyPlaceThing {

      public Vector  myRole;
        public Description myDescription;
        public Vector  myCommonInterface;

    }

Role.java

    import java.util.Vector;

    public class Role {

    public Vector  myMomentInterval;
        public PartyPlaceThing myPartyPlaceThing;
        public Vector  myCommonInterface;

    }

MomentInterval.java

    import java.util.Vector;

    public class MomentInterval {

    public Role myRole;
    public Vector  myMIDetail;
    public Vector  myCommonInterface;

    }

MIDetail.java

    public class MIDetail {

        public MomentInterval myMomentInterval;

    }

Now I want to persist the data in these classes in a database [mysql] where "tableName in DB == className in java"

I know that such attributes will be included as foreign keys but the problem is how will the tables basically be created?

e.g the table description would contain partyplacething as foreign key. This means that table of partyplacething must exist before table of description can be created. similar is the case with other classes thus creating a deadlock cuz I need tables of "role and description" before I can create partyplacething and so on. the only table that I can successfully create is of MIDetail (right now cuz it is independent).

How should I change my model so that my original relationships are maintained and I can successfully persist data in a database???

Ariful Islam
  • 7,639
  • 7
  • 36
  • 54
Arifah Azhar
  • 227
  • 1
  • 5
  • 17
  • :) no its not homework. i m working on tool development. just the database phase is left. and after evaluation of my classes i found out that i have this problem with the relationship in classes. i was lost on how to proceed. i looked on internet [2 days] and i just could not find a "spot on" for what i m looking for. that is y i thought about asking here. – Arifah Azhar Nov 20 '11 at 08:01

1 Answers1

2

Have a look at jpa and check the jpa tutorials.

Udo Held
  • 12,314
  • 11
  • 67
  • 93