il programma in java mi solleva questo messaggio d'errore An annotation processor threw an uncaught exception. Come lo posso risolvere?

Davide Acquarone

Nuovo Utente
2
0
Questo è il codice del programma Java che usa java persistence api (JPA)
package provajpa5;

-- rimosso, vedi messaggio più in basso --

Vi ho allegato il mio progetto java
Attendo una risposta
 

Allegati

  • provaJpa.zip
    19 KB · Visualizzazioni: 79
Ultima modifica da un moderatore:

Moffetta88

Moderatore
Staff Forum
Utente Èlite
20,465
12,881
CPU
i5-4690
Dissipatore
DEEPCOOL CAPTAIN 240EX
Scheda Madre
MSI Z97 U3 PLUS
HDD
KINGSTON SSD KC400 240GB
RAM
24GB BALLISTIX SPORT @2133MHz
GPU
STRIX GTX980 DC2OC
Audio
INTEGRATA
Monitor
AOC G2590VXQ
PSU
BEQUIET! System Power 7 500W
Case
DEEPCOOL MATREXX 55
Periferiche
NESSUNA
Net
EOLO 100
OS
UBUNTU/WINDOWS11
Gentilmente metti il codice dentro ai tag [CODE][/CODE] altrimenti è illeggibile
 
  • Mi piace
Reazioni: Mursey

Davide Acquarone

Nuovo Utente
2
0
Codice:
import entity.Product;
import java.time.LocalDate;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
ProvaJpa.java
/**
*
* @author win
*/
public class ProvaJpa5 {
private static void testJpa() {
EntityManagerFactory emf=Persistence.createEntityManagerFactory("provaJpa6PU");
EntityManager em=emf.createEntityManager();
System.out.println(em);
Product p=new Product();
p.setName("Tonno Rio Mare");
p.setExpirationDate(LocalDate.now());
em.persist(p);


em.close();
}

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
testJpa();
System.out.println("PROGRAMMA TERMINATO CORRETTAMENTE");
}

}
Product.java
package entity;

import java.io.Serializable;
import java.time.LocalDate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
*
* @author win
*/
@Entity
public class Product implements Serializable {

private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name ;
private double price ;
@Column(name="expiration_date")
private LocalDate expirationDate;

public Long getId() {
return id;
}



@Override
public int hashCode() {
int hash = 0;
hash += (getId() != null ? getId().hashCode() : 0);
return hash;
}

@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Product)) {
return false;
}
Product other = (Product) object;
if ((this.getId() == null && other.getId() != null) || (this.getId() != null && !this.id.equals(other.id))) {
return false;
}
return true;
}

@Override
public String toString() {
return "entity.Product[ id=" + getId() + " ]";
}

/**
* @return the name
*/
public String getName() {
return name;
}

/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}

/**
* @return the price
*/
public double getPrice() {
return price;
}

/**
* @param price the price to set
*/
public void setPrice(double price) {
this.price = price;
}

/**
* @return the expirationDate
*/
public LocalDate getExpirationDate() {
return expirationDate;
}

/**
* @param expirationDate the expirationDate to set
*/
public void setExpirationDate(LocalDate expirationDate) {
this.expirationDate = expirationDate;
}

}
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="provaJpa6PU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>entity.Product</class>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/provajpa"/>
<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="davide"/>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
 

Entra

oppure Accedi utilizzando
Discord Ufficiale Entra ora!