Java EclipseLink错误168和28019毁了我的CRUD JPA系统

Java EclipseLink错误168和28019毁了我的CRUD JPA系统,java,jpa,netbeans,eclipselink,crud,Java,Jpa,Netbeans,Eclipselink,Crud,所以我正在制作一个非常简单的crud系统,在我完成crud功能之前一切都很好,一切都变得更糟,程序不再启动,取而代之的是一个屏幕或错误消息,反复重复eclipselink错误168和28019,这是我的整个程序 出纳班 package SDev3Repeat; import javax.persistence.*; import java.util.Calendar; @Entity @Table(name = "CASHIER") @SuppressWarnings("Serializab

所以我正在制作一个非常简单的crud系统,在我完成crud功能之前一切都很好,一切都变得更糟,程序不再启动,取而代之的是一个屏幕或错误消息,反复重复eclipselink错误168和28019,这是我的整个程序

出纳班

package SDev3Repeat;

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

@Entity
@Table(name = "CASHIER")
@SuppressWarnings("SerializableClass")
public class Cashier {

@Id
private int cashierId;
private String name;
private String address;
@Temporal(TemporalType.DATE)
private Calendar DOB;                             //Date of Birth of the cashier

@OneToOne
@JoinColumn(name = "transID")
private Bill bill;

public Cashier(){

}

public Cashier(int cashierId, String name, String address, Calendar DOB) {
    this.cashierId = cashierId;
    this.name = name;
    this.address = address;
    this.DOB = DOB;
}

public int getCashierId() {
    return cashierId;
}

public void setCashierId(int cashierId) {
    this.cashierId = cashierId;
}

public String getName() {
    return name;
}

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

public String getAddress() {
    return address;
}

public void setAddress(String address) {
    this.address = address;
}

public Calendar getDOB() {
    return DOB;
}

public void setDOB(Calendar DOB) {
    this.DOB = DOB;
}

public Bill getTransaction() {
    return bill;
}

public void setTransaction(Bill bill) {
    this.bill = bill;
}

@Override
public String toString(){
    String d = String.format("%1$s %2$tB %2$td, %2$tY", 
                     " Date of Birth:", DOB);
    return "Cashier ID: "+cashierId+" |    Cashier Name: "+name+" |    Cashier Address: "+address+" |    Cashier Date Of Birth: "+d;
}
}
咖啡课

package SDev3Repeat;

import javax.persistence.*;

@Entity
@Table(name = "COFFEE")
@SuppressWarnings("SerializableClass")
public class Coffee {

@Id
private int coffeeId;
private String type;
private String size;
private double price;

@ManyToOne()
@JoinColumn(name = "TRANSID")
private Bill trans;

public Coffee(){

}

public Coffee(int coffeeId, String type, String size, double price){
    this.coffeeId = coffeeId;
    this.type = type;
    this.size = size;
    this.price = price;
}

public int getCoffeeId() {
    return coffeeId;
}

public void setCoffeeId(int coffeeId) {
    this.coffeeId = coffeeId;
}

public String getType() {
    return type;
}

public void setType(String type) {
    this.type = type;
}

public String getSize() {
    return size;
}

public void setSize(String size) {
    this.size = size;
}

public double getPrice() {
    return price;
}

public void setPrice(double price) {
    this.price = price;
}

public void setTrans(Bill trans) {
    this.trans = trans;
}

@Override
public String toString(){
    return " ID of Coffee: "+coffeeId+" |    Type of Coffee: " + type + " |    Size of Coffee: " + size + " |    Price of Coffee: " + price;
}


}
比尔班 包装SDev3Repeat

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

@Entity
@Table(name = "BILL")
@Inheritance( strategy = InheritanceType.JOINED )
@SuppressWarnings("SerializableClass")
public class Bill {

@Id
private int transId;
private double bill;
private final double VAT = .09;             //VAT for hot food and drinks is 9%


@OneToMany(mappedBy = "trans", cascade = CascadeType.PERSIST)
private List<Coffee> clist = new ArrayList<>();

@OneToOne(mappedBy="bill")
private Cashier cashier;

private String tempname = cashier.getName();

public Bill() {
}

public Bill(int transId, double bill,String name) {
    this.transId = transId;
    this.bill = bill;
    this.tempname = name;
}

public int getTransId() {
    return transId;
}

public void setTransId(int transId) {
    this.transId = transId;
}

public double getBill() {
    return bill;
}

public void setBill(double bill) {
    this.bill = bill;
}

public String getTempname() {
    return tempname;
}

public void setTempname(String tempname) {
    this.tempname = tempname;
}

public List<Coffee> getClist() {
    return clist;
}

public void setClist(List<Coffee> clist) {
    this.clist = clist;
}

public Cashier getCashier() {
    return cashier;
}

public void setCashier(Cashier cashier) {
    this.cashier = cashier;
}

@Override
public String toString() {
    String s="";
    for(int i=0;i<clist.size();i++) {
        s+= clist.get(i);
    }
    return s;
}  

public double calcBill(Double tempBill){
    bill = tempBill + (tempBill * VAT);
    return bill;
}

}
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="SDEVRepeatCAPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>SDev3Repeat.Cashier</class>
    <class>SDev3Repeat.Coffee</class>
    <class>SDev3Repeat.Bill</class>
    <properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
  <property name="javax.persistence.jdbc.user" value="hr"/>
  <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
  <property name="javax.persistence.jdbc.password" value="passhr"/>
  <!--      <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@10.10.2.7:1521/global1"/>
  <property name="javax.persistence.jdbc.user" value=""/>
  <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
  <property name="javax.persistence.jdbc.password" value=""/>-->
  <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>

我有一种感觉,这是我的关系映射问题,但我无法找出什么是错误的内部异常:java.lang.reflect.InvocationTargetException目标调用异常:java.lang.NullPointerException表明Bill构造函数存在问题,但您显示的堆栈缺少详细信息。我想你的增值税应该标记为暂时性的。我让增值税暂时性的,但不幸的是,它根本没有解决我的问题或改变产量,还有其他想法吗?还有,你所说的“显示的堆栈缺少详细信息”是什么意思?我提供了我编写和接收的所有信息。你的构造函数正在导致一个NPE-String tempname=cashier.getName();会有原因的。非常感谢你,我真的被难住了,你帮我省了很多麻烦我感觉这是我的关系映射问题,但我不知道是什么错内部异常:java.lang.reflect.InvocationTargetException目标调用异常:java.lang.NullPointerException表示Bill构造函数有问题,但您显示的堆栈缺少详细信息。我想你的增值税应该标记为暂时性的。我让增值税暂时性的,但不幸的是,它根本没有解决我的问题或改变产量,还有其他想法吗?还有,你所说的“显示的堆栈缺少详细信息”是什么意思?我提供了我编写和接收的所有信息。你的构造函数正在导致一个NPE-String tempname=cashier.getName();非常感谢你,我真的被难倒了,你帮我省去了很多麻烦
<?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="SDEVRepeatCAPU" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>SDev3Repeat.Cashier</class>
    <class>SDev3Repeat.Coffee</class>
    <class>SDev3Repeat.Bill</class>
    <properties>
  <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
  <property name="javax.persistence.jdbc.user" value="hr"/>
  <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
  <property name="javax.persistence.jdbc.password" value="passhr"/>
  <!--      <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@10.10.2.7:1521/global1"/>
  <property name="javax.persistence.jdbc.user" value=""/>
  <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
  <property name="javax.persistence.jdbc.password" value=""/>-->
  <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
[EL Info]: 2017-08-22 17:45:37.248--ServerSession(1203142603)--EclipseLink, version: Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd
[EL Severe]: 2017-08-22 17:45:38.744--ServerSession(1203142603)--Exception 
[EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): 
org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Problem in creating new instance using the default constructor.  The default constructor triggered an exception.
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.NullPointerException
Descriptor: RelationalDescriptor(SDev3Repeat.Bill --> [DatabaseTable(BILL)])

Runtime Exceptions: 
---------------------------------------------------------

[EL Info]: connection: 2017-08-22 17:45:38.749--ServerSession(1203142603)--file:/C:/Users/Aran/Documents/NetBeansProjects/SDEV3RepeatCA/build/classes/_SDEVRepeatCAPU logout successful
Exception in thread "main" javax.persistence.PersistenceException: Exception 
[EclipseLink-28019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [SDEVRepeatCAPU] failed. Close all factories for this PersistenceUnit.
[EL Severe]: ejb: 2017-08-22 17:45:38.758--ServerSession(1203142603)--Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Problem in creating new instance using the default constructor.  The default constructor triggered an exception.
Exception [EclipseLink-168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.NullPointerException
Exception Description: Problem in creating new instance using the default constructor.  The default constructor triggered an exception.
Descriptor: RelationalDescriptor(SDev3Repeat.Bill --> [DatabaseTable(BILL)])

Internal Exception: java.lang.reflect.InvocationTargetException
Runtime Exceptions: 
---------------------------------------------------------

Target Invocation Exception: java.lang.NullPointerException
Descriptor: RelationalDescriptor(SDev3Repeat.Bill --> [DatabaseTable(BILL)])

Runtime Exceptions: 
---------------------------------------------------------

at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:820)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:760)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:204)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:182)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getDatabaseSession(EntityManagerFactoryImpl.java:527)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:140)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at SDev3Repeat.TestCoffee.main(TestCoffee.java:15)
Caused by: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Deployment of PersistenceUnit [SDEVRepeatCAPU] failed. Close all factories for this PersistenceUnit.
Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Problem in creating new instance using the default constructor.  The default constructor triggered an exception.
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.NullPointerException
Descriptor: RelationalDescriptor(SDev3Repeat.Bill --> [DatabaseTable(BILL)])

Runtime Exceptions: 
---------------------------------------------------------

at org.eclipse.persistence.exceptions.EntityManagerSetupException.deployFailed(EntityManagerSetupException.java:238)
... 10 more
Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.IntegrityException
Descriptor Exceptions: 
---------------------------------------------------------

Exception [EclipseLink-168] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Problem in creating new instance using the default constructor.  The default constructor triggered an exception.
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.NullPointerException
Descriptor: RelationalDescriptor(SDev3Repeat.Bill --> [DatabaseTable(BILL)])

Runtime Exceptions: 
---------------------------------------------------------

at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:696)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:632)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:568)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:799)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:743)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:239)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:685)
... 8 more
Java Result: 1
BUILD SUCCESSFUL (total time: 4 seconds)