Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8368609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:25:47+00:00 2026-06-09T13:25:47+00:00

Suppose i have a classes like this @Entity public class Customer implements Serializable {

  • 0

Suppose i have a classes like this

@Entity
public class Customer implements Serializable {
    private int id;
    private String firstName;
    private String lastName;
    private Referee referee;
    private Collection<Address> addresses;
    private Collection<Account> accounts;
    .....
} //end of class Customer

@Entity
public class Referee implements Serializable {
    private int id;
    private String name;
    private String comments;
    ....
} //end of class Referee

@Entity 
public class Account implements Serializable {
    private int id;
    private double balance;
    private String accountType;
    ...
}

@Entity
public class Address implements Serializable {
    private int id;
    private String addressLine;
    private String country;
    private String postCode;
    ...
}

Now if i make Table in database of name Customer. Then what type will i use for the type Referee, Collection<Address> and Collection<Account>. Like if i make column id, then it’s type will be INTEGER, String changes to VARCHAR but what type do i use for Collection and Referee?
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:25:48+00:00Added an answer on June 9, 2026 at 1:25 pm

    The referee field would be integer in the database because it has to store the id field of the Referee class which is of type int.

    Collections will also be based on the id’s of classes. For 1 to N relationships a column on the N side can be used. So if a Customer has multiple addresses but an address never belongs to more then one Customer then you can store the id of the customer in the address table to store the relationship. If it is N to M you will need an additional so called join table which stores paires of customer id + address id. Same story for accounts.

    BTW many JPA providers can generate the tables for you see their manual for how.

    If you are new to JPA you should get a good book about it. A couple of tutorials will not give you enough in depth knowledge to use it well. Personally I have read Pro EJB 3: Java Persistence API.

    When learning JPA the netbeans IDE can be a great help as well as it will give you lots of useful hints for annotating your entities. It will for instance notice that your collections need additional annotations and will give you choices for one to many or many to many and uni- or bidirectional.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Supposed I have two classes like this: public class Parent { public string Id
Suppose we have two classes: class Base { private: int x; public: void f();
Suppose you have 2 classes like so: public class ClassA { public int X
I am a NHibernate newbie. Suppose you have a Customer class like this public
suppose you have two (or more) classes with private member vectors: class A {
Suppose, I have following classes: public class DisposableObj : IDisposable { public ChildObj CreateObj();
Suppose I have classes like: class A { B getB(); C getC(); } class
Suppose I have two classes like so: class Parent def say I am a
Suppose I have these two objects: public class Object1 { string prop1; string prop2;
Suppose I have a class Baz that inherits from classes Foo and Bar ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.