1

I am trying to create an objectdb using JPA. The following code below is what i have done but am not sure if i have done it correctly. The entity is student and the attributes are fristname, surname etc. Would anyone know if i have set it out right of if its wrong?

package Student;
 import java.io.Serializable;
import java.sql.Date;

import javax.persistence.*;

@Entity
    public class students implements Serializable {
    private static final long serialVersionUID = 1L;

    @studentid @GeneratedValue
    private long id;
  } 

    public class studentdetails {
    int studentid;
    String firstname;
    String surname;
    char gender;
    Date dob;
    String address1;
    String address2;
    String address3;
    char postcode;
    int phonenumber;
    int courseid;

    }
ObjectDB
  • 1,294
  • 7
  • 8
  • 2
    What happens when you try loading, using and persisting these entities? Please respect the Java naming conventions: packages are all lowercase. Classes start with an uppercase letter and are CamelCased. Variables start with a lowercase letter and are camelCased. A class representing a student should be named Student, not Students. And why do you have a separate, non-entity-annotated class for StudentDetails, and nothing in the Student entity? – JB Nizet Apr 14 '13 at 15:13

1 Answers1

1

The studentdetails class cannot be used to persist data using JPA, since it is not defined as a persistable type (entity, embeddable) and even not as serializable.

There is also no connection between students and studentdetails.

ObjectDB
  • 1,294
  • 7
  • 8