1
votes

Unfortunatly, additional entity name, schema name are not works in this case. I don't understand a description of this exeption. What it means?

Exception [EclipseLink-93] (Eclipse Persistence Services -

2.6.4.qualifier): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [drivers] is not present in this descriptor. Descriptor: RelationalDescriptor(com.spring_test2.jpa.models.Tickets --> [DatabaseTable(tickets)])

Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.4.qualifier): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [tickets] is not present in this descriptor. Descriptor: RelationalDescriptor(com.spring_test2.jpa.models.Drivers --> [DatabaseTable(drivers)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.4.qualifier): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(com.spring_test2.jpa.models.Tickets --> [DatabaseTable(tickets)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.4.qualifier): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(com.spring_test2.jpa.models.Drivers --> [DatabaseTable(drivers)])

Nothing especial in my entities i cannot find, they are well tested by me.

Tickets

@Entity
@Table(name = "tickets")
public class Tickets {

    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @Column(name = "from_point")
    @Size(min = 0, max = 255)
    private String from;

    @Column(name = "throw")
    @Size(min = 0, max = 255)
    private String throwp; //throw point

    @Column(name = "to_point")
    @Size(min = 0, max = 255)
    private String to;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "city_id")
    private Cities city;

    @Column(name = "hum")
    private Integer hum;

    @Column(name = "cost")
    private Integer cost;

    @Column(name = "phone")
    private Integer phone;

    @Column(name = "date", nullable = false, insertable = false, updatable = false, columnDefinition = "Datetime DEFAULT CURRENT_TIMESTAMP")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "ticket_status_id")
    private TicketStatuses ticketStatus;

    @OneToMany(mappedBy = "driver", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<TicketsDrivers> driver;

setters/getters

Drivers

@Entity
@Table(name = "drivers")
public class Drivers {

    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Column(name = "id")
    private Integer id;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "role_id")
    private Roles role;

    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "profile_id")
    private Profiles profile;

    @Column(name = "name")
    @Size(min = 0, max = 255)
    private String name;

    @Column(name = "phone")
    @Size(min = 0, max = 255)
    private String phone;

    @Column(name = "mail")
    @Size(min = 0, max = 255)
    private String mail;

    @Column(name = "login")
    @Size(min = 0, max = 32)
    private String login;

    @Column(name = "password")
    @Size(min = 0, max = 32)
    private String password;

    @OneToMany(mappedBy = "ticket", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<TicketsDrivers> tickets;

setters/getters

And TicketsDrivers

@Entity
@Table(name = "tickets_drivers")
public class TicketsDrivers {

@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "id")
private Integer id;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "driver_id")
private Drivers driver;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ticket_id")
private Tickets ticket;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ticket_status_id")
private TicketStatuses ticket_status;

setters/getters

persistence.xml

<persistence 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_2_0.xsd"
             version="2.0">

    <persistence-unit name="Services" transaction-type="RESOURCE_LOCAL">
        <description>
            Maven Test JPA
        </description>
        <!--provider>org.hibernate.ejb.HibernatePersistence</provider-->
        <class>com.spring_test2.jpa.models.Test</class>
        <class>com.spring_test2.jpa.models.Cities</class>
        <class>com.spring_test2.jpa.models.Countries</class>
        <class>com.spring_test2.jpa.models.Admins</class>
        <class>com.spring_test2.jpa.models.dictionaries.TicketStatuses</class>
        <class>com.spring_test2.jpa.models.dictionaries.StaticPages</class>
        <class>com.spring_test2.jpa.models.dictionaries.Sources</class>
        <class>com.spring_test2.jpa.models.dictionaries.Roles</class>
        <class>com.spring_test2.jpa.models.dictionaries.ProfileTypes</class>
        <class>com.spring_test2.jpa.models.dictionaries.Partners</class>
        <class>com.spring_test2.jpa.models.dictionaries.Newsletter</class>
        <class>com.spring_test2.jpa.models.dictionaries.DriverStatuses</class>
        <class>com.spring_test2.jpa.models.Auto</class>
        <class>com.spring_test2.jpa.models.Drivers</class>
        <class>com.spring_test2.jpa.models.Models</class>
        <class>com.spring_test2.jpa.models.Profiles</class>
        <class>com.spring_test2.jpa.models.Tickets</class>
        <class>com.spring_test2.jpa.models.TicketsDrivers</class>
        <class>com.spring_test2.jpa.models.UndergroundLines</class>
        <class>com.spring_test2.jpa.models.UndergroundStations</class>

        <properties>
            <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
            <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/spring_test2" />
            <property name="javax.persistence.jdbc.user" value="root" />
            <property name="javax.persistence.jdbc.password" value="pwd" />
            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>

            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
        </properties>

    </persistence-unit>

</persistence>

Also changing of hibernate.hbm2ddl.auto from "update" to "create" for example wasn't success

P.S.

After @ManyToOne lines in Tickets & Drivers entities were commented an exeption is gone. But whats wrong in this case.

In this project I have ticket <-> tickets_drivers <-> drivers many-to-many connection and I didn't use @ManyToMany because google said that if I have one or more additional fields in joining table I must use @OneToMany twice. Can It be a reason of this error?!

1
Why tag a question against Hibernate when the error relates to EclipseLink (a different JPA provider)?! - Neil Stockton
Yes, I have removed it - Nesquik27
and why not remove all of that Hibernate configuration and the line about changing some hibernate property? Oh, and the openJPA property! And then tag it as Eclipselink as well! - Neil Stockton
Tag was added, I have removed these lines, they were copy pasted from another project - Nesquik27
hard to imagine behaviour with such chaotic (mixed) annotations / configuration - Jacek Cz

1 Answers

1
votes

Your mappings are messed up, likely from inserting an intermediary entity in place of the ManyToMany relationship. The error states there is no 'driver', and if you look at your tickets.driver mapping, it uses mappedby of:

@OneToMany(mappedBy = "driver", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<TicketsDrivers> driver;

This is stating TicketDrivers has a driver relationship back to Tickets. It does not, as TicketDrivers.driver maps to Drivers, hence the exception. This should have been mappedBy "ticket":

@OneToMany(mappedBy = "ticket", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<TicketsDrivers> driver;

You have the same problem within Driver as well. The error with IDs is different, and either is occurring because the entity processing was incomplete due to the above errors, or because it is picking up classes that are different to what you have posted. Clear them up and post a new question if the error on IDs persist.