Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Is TABLE_PER_CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6)
Is TABLE_PER_CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #481227] Thu, 20 August 2009 08:08 Go to next message
Martin is currently offline MartinFriend
Messages: 35
Registered: July 2009
Member
Hello,

I would like to know if InheritanceType.TABLE_PER_CLASS is supposed to
work with eclipselink-2.0.0.v20090731-r4765 (milestone 6). If I try to use
it I always get the following exception for ManyToMany bidirectional
relations:

[java] Exception [EclipseLink-80] (Eclipse Persistence Services -
2.0.0.v20090731-r4765):
org.eclipse.persistence.exceptions.DescriptorException
[java] Exception Description: The relation key field
[DEPARTMENT.departments_ID] for this mapping must exist in the relation
table.
[java] Mapping:
org.eclipse.persistence.mappings.ManyToManyMapping[students]
[java] Descriptor: RelationalDescriptor(Department -->
[DatabaseTable(DEPARTMENT)])

Best regards,
Martin
Re: Is TABLE_PER_CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #481849 is a reply to message #481227] Mon, 24 August 2009 14:36 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

TABLE_PER_CLASS should work in v2. It may be possible there is an issue
with m-m's.

Please include your mappings for both sides of the relationship, and
hierarchy.

---
James


James : Wiki : Book : Blog : Twitter
Re: Is TABLE_PER_CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #482163 is a reply to message #481849] Tue, 25 August 2009 14:50 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2009
Junior Member
For my example I'm using the following two entity classes Student and Department:
import java.util.*;
import javax.persistence.*;

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Student {
    @Id
    @GeneratedValue(strategy=GenerationType.TABLE)
    private int id;

    private String name;

    @ManyToMany
    private Collection<Department> departments;

    public Student() {
        departments = new ArrayList<Department>();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void addDepartment(Department department) {
        if (!getDepartments().contains(department)) {
            getDepartments().add(department);
        }
        if (!department.getStudents().contains(this)) {
            department.getStudents().add(this);
        }
    }

    public Collection<Department> getDepartments() {
        return departments;
    }

    public void setDepartment(Collection<Department> departments) {
        this.departments = departments;
    }

    public String toString() {
        return "Student id: " + getId() + ", name: " + getName();
    }
}


import java.util.*;
import javax.persistence.*;

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class Department {
    @Id
    @GeneratedValue(strategy=GenerationType.TABLE)
    private int id;

    private String name;

    @ManyToMany(mappedBy="departments")
    private Collection<Student> students;

    public Department(){
      students = new ArrayList<Student>();
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String deptName) {
        this.name = deptName;
    }

    public void addStudent(Student student) {
      if (!getStudents().contains(student)) {
          getStudents().add(student);
      }
      if (!student.getDepartments().contains(this)) {
          student.getDepartments().add(this);
      }
    }

    public Collection<Student> getStudents() {
      return students;
    }

    public void setStudent(Collection<Student> students) {
      this.students = students;
    }

    public String toString() {
        return "Department id: " + getId() + ", name: " + getName();
    }
}


I have a simple Main class which just does:
import java.util.*;
import javax.persistence.*;

public class Main {
  public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.err.println("No provider (hibernate|eclipselink) specified.");
        System.exit(1);
    }
    String provider = args[0];
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("JPAService_"+provider);
    EntityManager em = emf.createEntityManager();

    em.getTransaction().begin();

    Student student1 = new Student();
    em.persist(student1);
    student1.setName("Joe");

    Student student2 = new Student();
    em.persist(student2);
    student2.setName("Tom");

    Department dept = new Department();
    em.persist(dept);
    dept.setName("MyDepartment");
    dept.addStudent(student1);
    dept.addStudent(student2);

    em.flush();
    em.getTransaction().commit();

    System.out.println("Students:");
    Query query = em.createQuery("SELECT e FROM Student e");
    List<Student> students = (List<Student>) query.getResultList();
    for (Student student : students) {
        System.out.println(student);
    }

    System.out.println("Departments:");
    query = em.createQuery("SELECT d FROM Department d");
    List<Department> departments = (List<Department>) query.getResultList();
    for (Department department : departments) {
        System.out.println(department);
    }

    em.close();
    emf.close();
  }
}


I'm using the following persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"  xmlns="http://java.sun.com/xml/ns/persistence"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="JPAService_hibernate" transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>Department</class>
        <class>Student</class>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
            <property name="hibernate.connection.username" value="sa"/>
            <property name="hibernate.connection.password" value=""/>
            <property name="hibernate.connection.url" value="jdbc:hsqldb:data/tutorial"/>
        </properties>
    </persistence-unit>

    <persistence-unit name="JPAService_eclipselink" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>Department</class>
        <class>Student</class>
        <properties>
            <property name="eclipselink.ddl-generation" value="create-tables"/>
            <property name="eclipselink.ddl-generation.output-mode" value="database"/>
            <property name="eclipselink.target-server" value="none"/>
            <property name="eclipselink.target-database" value="HSQL"/>
            <property name="javax.persistence.jdbc.user" value="sa"/>
            <property name="javax.persistence.jdbc.password" value=""/>
            <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:data/tutorial"/>
            <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
            <property name="eclipselink.logging.logger" value="JavaLogger"/>
            <property name="eclipselink.logging.level" value="FINEST"/>
        </properties>
    </persistence-unit>
</persistence>

When using hibernate as a persistence provider everything works as expected. When using eclipselink the code throws exceptions as shown in my first message. I would be very happy if someone could tell me what's wrong with the code.

Best regards,
Martin

[Updated on: Tue, 25 August 2009 15:25]

Report message to a moderator

Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #482416 is a reply to message #482163] Wed, 26 August 2009 13:24 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please include your mappings for both sides of the relationship, and
hierarchy.

Also please include the full exception stack trace.

Your column has mixed case, which may be related to the issue, try setting
the column names in your mappings as upper case.


James : Wiki : Book : Blog : Twitter
Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #482477 is a reply to message #482416] Wed, 26 August 2009 17:22 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2009
Junior Member
Hello James,

thank you for your answer. I'm not quite sure what you mean by "include your mappings for both sides of the relationship". According to the JPA specification the annotations I provided for the mappings are sufficient. As far as I understood the specification (see below), table and column names are automatically created by the persistence provider if the annotations are omitted. I have a small self contained example which works with hibernate but fails with eclipselink when InheritanceType.TABLE_PER_CLASS is used. With InheritanceType.SINGLE_TABLE my example works with both providers. Unfortunately I haven't found out yet how I could attach my example to a message in this forum. Thanks again for looking into this.

Martin

2.10.4 Bidirectional ManyToMany Relationships
       Assuming that:
                Entity A references a collection of Entity B.
                Entity B references a collection of Entity A.
                Entity A is the owner of the relationship.
       The following mapping defaults apply:
                Entity A is mapped to a table named A.
                Entity B is mapped to a table named B.
                There is a join table that is named A_B (owner name first). This join table has two foreign key
                columns. One foreign key column refers to table A and has the same type as the primary key of
                table A. The name of this foreign key column is formed as the concatenation of the following:
                the name of the relationship property or field of entity B; "_"; the name of the primary key col-
                umn in table A. The other foreign key column refers to table B and has the same type as the pri-
                mary key of table B. The name of this foreign key column is formed as the concatenation of the
                following: the name of the relationship property or field of entity A; "_"; the name of the pri-
                mary key column in table B.
       Example:
       @Entity
       public class Project {
           private Collection<Employee> employees;
           @ManyToMany
           public Collection<Employee> getEmployees() {
              return employees;
           }
           public void setEmployees(Collection<Employee> employees) {
              this.employees = employees;
           }
           ...
       }

       @Entity
       public class Employee {
           private Collection<Project> projects;
           @ManyToMany(mappedBy="employees")
           public Collection<Project> getProjects() {
               return projects;
           }
           public void setProjects(Collection<Project> projects) {
               this.projects = projects;
           }
           ...
       }
In this example:
          Entity Project references a collection of Entity Employee.
          Entity Employee references a collection of Entity Project.
          Entity Project is the owner of the relationship.
The following mapping defaults apply:
          Entity Project is mapped to a table named PROJECT.
          Entity Employee is mapped to a table named EMPLOYEE.
          There is a join table that is named PROJECT_EMPLOYEE (owner name first). This join table
          has two foreign key columns. One foreign key column refers to table PROJECT and has the
          same type as the primary key of PROJECT. The name of this foreign key column is
          PROJECTS_<PK of PROJECT>, where <PK of PROJECT> denotes the name of the primary
          key column of table PROJECT. The other foreign key column refers to table EMPLOYEE and
          has the same type as the primary key of EMPLOYEE. The name of this foreign key column is
          EMPLOYEES_<PK of EMPLOYEE>, where <PK of EMPLOYEE> denotes the name of the
          primary key column of table EMPLOYEE.


This is the entire output created by my example with eclipselink:
     [java] Aug 26, 2009 7:12:08 PM org.eclipse.persistence.session.file:.../jpa/JPA-ManyToManyBidirectional/build/-JPAService_eclipselink
     [java] INFO: EclipseLink, version: Eclipse Persistence Services - 2.0.0.v20090731-r4765
     [java] Aug 26, 2009 7:12:08 PM org.eclipse.persistence.session.file:.../jpa/JPA-ManyToManyBidirectional/build/-JPAService_eclipselink
     [java] SEVERE:
     [java] Local Exception Stack:
     [java] Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.IntegrityException
     [java] Descriptor Exceptions:
     [java] ---------------------------------------------------------

     [java] Exception [EclipseLink-80] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: The relation key field [DEPARTMENT.departments_ID] for this mapping must exist in the relation table.
     [java] Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[students]
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: A non-read-only mapping must be defined for the sequence number field.
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Runtime Exceptions:
     [java] ---------------------------------------------------------

     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:263)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:135)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:187)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:175)
     [java]     at Main.main(Main.java:12)

     [java] Descriptor Exceptions:
     [java] ---------------------------------------------------------


     [java] Local Exception Stack:
     [java] Exception [EclipseLink-80] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: The relation key field [DEPARTMENT.departments_ID] for this mapping must exist in the relation table.
     [java] Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[students]
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])
     [java]     at org.eclipse.persistence.exceptions.DescriptorException.relationKeyFieldNotProperlySpecified(DescriptorException.java:1407)
     [java]     at org.eclipse.persistence.mappings.RelationTableMechanism.initializeSourceRelationKeys(RelationTableMechanism.java:464)
     [java]     at org.eclipse.persistence.mappings.RelationTableMechanism.initialize(RelationTableMechanism.java:304)
     [java]     at org.eclipse.persistence.mappings.ManyToManyMapping.initialize(ManyToManyMapping.java:394)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.initialize(ClassDescriptor.java:2608)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:449)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:263)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:135)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:187)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:175)
     [java]     at Main.main(Main.java:12)


     [java] Local Exception Stack:
     [java] Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: A non-read-only mapping must be defined for the sequence number field.
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])
     [java]     at org.eclipse.persistence.exceptions.DescriptorException.mappingForSequenceNumberField(DescriptorException.java:910)
     [java]     at org.eclipse.persistence.internal.descriptors.ObjectBuilder.validate(ObjectBuilder.java:2815)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.selfValidationAfterInitialization(ClassDescriptor.java:3490)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.validateAfterInitialization(ClassDescriptor.java:5212)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.postInitialize(ClassDescriptor.java:3209)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:463)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:263)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:135)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:187)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:175)
     [java]     at Main.main(Main.java:12)

     [java] Runtime Exceptions:
     [java] ---------------------------------------------------------
     [java] Aug 26, 2009 7:12:08 PM org.eclipse.persistence.session.file:.../jpa/JPA-ManyToManyBidirectional/build/-JPAService_eclipselink.ejb
     [java] SEVERE:
     [java] Local Exception Stack:
     [java] Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.IntegrityException
     [java] Descriptor Exceptions:
     [java] ---------------------------------------------------------

     [java] Exception [EclipseLink-80] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: The relation key field [DEPARTMENT.departments_ID] for this mapping must exist in the relation table.
     [java] Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[students]
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: A non-read-only mapping must be defined for the sequence number field.
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Runtime Exceptions:
     [java] ---------------------------------------------------------

     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:263)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:135)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:187)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:175)
     [java]     at Main.main(Main.java:12)

     [java] Descriptor Exceptions:
     [java] ---------------------------------------------------------


     [java] Local Exception Stack:
     [java] Exception [EclipseLink-80] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: The relation key field [DEPARTMENT.departments_ID] for this mapping must exist in the relation table.
     [java] Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[students]
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])
     [java]     at org.eclipse.persistence.exceptions.DescriptorException.relationKeyFieldNotProperlySpecified(DescriptorException.java:1407)
     [java]     at org.eclipse.persistence.mappings.RelationTableMechanism.initializeSourceRelationKeys(RelationTableMechanism.java:464)
     [java]     at org.eclipse.persistence.mappings.RelationTableMechanism.initialize(RelationTableMechanism.java:304)
     [java]     at org.eclipse.persistence.mappings.ManyToManyMapping.initialize(ManyToManyMapping.java:394)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.initialize(ClassDescriptor.java:2608)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:449)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:263)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:135)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:187)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:175)
     [java]     at Main.main(Main.java:12)


     [java] Local Exception Stack:
     [java] Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: A non-read-only mapping must be defined for the sequence number field.
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])
     [java]     at org.eclipse.persistence.exceptions.DescriptorException.mappingForSequenceNumberField(DescriptorException.java:910)
     [java]     at org.eclipse.persistence.internal.descriptors.ObjectBuilder.validate(ObjectBuilder.java:2815)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.selfValidationAfterInitialization(ClassDescriptor.java:3490)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.validateAfterInitialization(ClassDescriptor.java:5212)
     [java]     at org.eclipse.persistence.descriptors.ClassDescriptor.postInitialize(ClassDescriptor.java:3209)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:463)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:263)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:135)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:187)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:175)
     [java]     at Main.main(Main.java:12)

     [java] Runtime Exceptions:
     [java] ---------------------------------------------------------
     [java] Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.IntegrityException
     [java] Descriptor Exceptions:
     [java] ---------------------------------------------------------

     [java] Exception [EclipseLink-80] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: The relation key field [DEPARTMENT.departments_ID] for this mapping must exist in the relation table.
     [java] Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[students]
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: A non-read-only mapping must be defined for the sequence number field.
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Runtime Exceptions:
     [java] ---------------------------------------------------------

     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:284)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:135)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:187)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:175)
     [java]     at Main.main(Main.java:12)
     [java] Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.IntegrityException
     [java] Descriptor Exceptions:
     [java] ---------------------------------------------------------

     [java] Exception [EclipseLink-80] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: The relation key field [DEPARTMENT.departments_ID] for this mapping must exist in the relation table.
     [java] Mapping: org.eclipse.persistence.mappings.ManyToManyMapping[students]
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Exception [EclipseLink-41] (Eclipse Persistence Services - 2.0.0.v20090731-r4765): org.eclipse.persistence.exceptions.DescriptorException
     [java] Exception Description: A non-read-only mapping must be defined for the sequence number field.
     [java] Descriptor: RelationalDescriptor(Department --> [DatabaseTable(DEPARTMENT)])

     [java] Runtime Exceptions:
     [java] ---------------------------------------------------------

     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:478)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:406)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:671)
     [java]     at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:633)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:233)
     [java]     at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:263)
     [java]     ... 4 more
     [java] Java Result: 1
Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #483485 is a reply to message #482477] Tue, 01 September 2009 17:38 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please include your source files for your Entity classes which include the
annotations you are using, or include the XML if you are using the orm.xml
to define the mappings.

Just past them into your post, I probably don't need your entire source
file, but at a minimum include the annotations that you specified and
their values, otherwise I have no way to verify or recreate your issue.
It seems the column names you are giving are wrong, or their is a bug in
the auto mapping code if you have not set any.


James : Wiki : Book : Blog : Twitter
Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #483562 is a reply to message #483485] Wed, 02 September 2009 06:45 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2009
Junior Member
Hello James,

for the source code of my example and the persistence.xml file please see my posting from Tue, 25 August 2009 10:50. Thanks again.

Martin
Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #483853 is a reply to message #483562] Thu, 03 September 2009 11:37 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

I don't see the source to you entity classes in that email. Perhaps it
was attached and the web interface does not show attachments. Please
inline the source into the message.


James : Wiki : Book : Blog : Twitter
Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #483950 is a reply to message #483853] Thu, 03 September 2009 18:05 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2009
Junior Member
Hello James,

the source code is embedded in the message. When I use the following link I can see the source code.

Martin

http://www.eclipse.org/forums/index.php?t=rview&goto=483 853#msg_483853\n\nIf
Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #484615 is a reply to message #483950] Tue, 08 September 2009 14:10 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This seems to be a bug. You may wish to try the latest EclipseLink build to see if it was fixed, or log a bug.

You may also be able to workaround the issue be setting the @JoinTable explicitly.



James : Wiki : Book : Blog : Twitter
Re: Is TABLE PER CLASS supposed to work with eclipselink-2.0.0.v20090731-r4765 (m6) [message #484883 is a reply to message #484615] Wed, 09 September 2009 15:34 Go to previous message
No real name is currently offline No real nameFriend
Messages: 5
Registered: August 2009
Junior Member
Thanks again James. I have written a bug report:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=288955
Previous Topic:Database Schema
Next Topic:Cache issue
Goto Forum:
  


Current Time: Fri Nov 21 19:23:18 GMT 2014

Powered by FUDForum. Page generated in 0.02385 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software