小编Aed*_*ahl的帖子

JPA错误:关系不存在

我无法弄清楚我做错了什么.我正在学习JPA映射到关系数据库,通过在网上学习一些教程,但找不到一个直截了当的教程.当我运行我的项目时,它给了我一个错误.我想这是坚持不懈的em.persist();.如果我评论该行,所有看起来都很好,没有错误,但显然没有数据写入表.这是我的代码:

persistence.xml(生成,未触及)

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
    <persistence-unit name="RESTappPU" transaction-type="RESOURCE_LOCAL">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>restapp.entities.ContactList</class>
        <properties>
            <property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/postgres"/>
            <property name="javax.persistence.jdbc.user" value="postgres"/>
            <property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver"/>
            <property name="javax.persistence.jdbc.password" value="postgres"/>
        </properties>
    </persistence-unit>
</persistence>
Run Code Online (Sandbox Code Playgroud)

实体类(生成,未触及) - 我是否需要在此处添加一些额外的"关系"方法?

package restapp.entities;

imports [...]

@Entity
@Table(name = "ContactList")
@NamedQueries({
    @NamedQuery(name = "ContactList.findAll", query = "SELECT c FROM ContactList c"),
    @NamedQuery(name = "ContactList.findByFirstname", query = "SELECT c FROM ContactList c WHERE c.firstname = :firstname"),
    @NamedQuery(name = "ContactList.findByLastname", query = "SELECT c FROM ContactList c …
Run Code Online (Sandbox Code Playgroud)

java postgresql jpa runtime-error eclipselink

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

eclipselink ×1

java ×1

jpa ×1

postgresql ×1

runtime-error ×1