不幸的是,在这种情况下,附加的实体名称,模式名称不起作用。我不理解这个例子的描述。这意味着什么?
异常[EclipseLink-93](Eclipse持久性服务 -
2.6.4.qualifier):org.eclipse.persistence.exceptions.DescriptorException异常 说明:此描述符中不存在表[驱动程序]。 描述符:RelationalDescriptor(com.spring_test2.jpa.models.Tickets - > [DatabaseTable(门票)])
异常[EclipseLink-93](Eclipse持久性服务 - 2.6.4.qualifier):org.eclipse.persistence.exceptions.DescriptorException异常 说明:此描述符中不存在表[ticket]。 描述符:RelationalDescriptor(com.spring_test2.jpa.models.Drivers - > [DatabaseTable(司机)])
异常[EclipseLink-41](Eclipse持久性服务 - 2.6.4.qualifier):org.eclipse.persistence.exceptions.DescriptorException异常 描述:必须为序列定义非只读映射 数字字段。描述: RelationalDescriptor(com.spring_test2.jpa.models.Tickets - > [DatabaseTable(门票)])
异常[EclipseLink-41](Eclipse持久性服务 - 2.6.4.qualifier):org.eclipse.persistence.exceptions.DescriptorException异常 描述:必须为序列定义非只读映射 数字字段。描述: RelationalDescriptor(com.spring_test2.jpa.models.Drivers - > [DatabaseTable(司机)])
在我找不到的实体中没有任何特别的东西,它们经过我的测试。
门票
@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
驱动
@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
和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>
同样从&#34;更新&#34;更改hibernate.hbm2ddl.auto到&#34;创造&#34;例如,没有成功
P.S。
在Tickets&amp;中的@ManyToOne行之后驱动程序实体被评论说,一个例子消失了。但在这种情况下有什么不对。
在这个项目中我有票&lt; - &gt; tickets_drivers&lt; - &gt;驱动程序多对多连接,我没有使用@ManyToMany因为google说如果我在连接表中有一个或多个附加字段,我必须使用@OneToMany两次。可能是这个错误的原因吗?!
答案 0 :(得分:1)
您的映射会混乱,可能是插入中间实体代替ManyToMany关系。错误表明没有'driver',如果你查看你的tickets.driver映射,它使用的映射为:
@OneToMany(mappedBy = "driver", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<TicketsDrivers> driver;
这说明TicketDrivers与Tickets有一个驱动关系。它没有,因为TicketDrivers.driver映射到Drivers,因此异常。这应该已经被映射为“票证”:
@OneToMany(mappedBy = "ticket", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<TicketsDrivers> driver;
您在驱动程序中也遇到同样的问题。 ID的错误是不同的,并且正在发生,因为实体处理由于上述错误而不完整,或者因为它正在拾取与您发布的内容不同的类。如果ID上的错误仍然存在,请清除它们并发布新问题。