Biagio said:
@OneToOne
@JoinColumn(name = "codlinea", referencedColumnName="codlinea",
unique = true, nullable = false, insertable = false, updatable =
false)
private Linee linee;
the error is on EntityManagerFactory
Exception in thread "main" javax.persistence.PersistenceException:
[PersistenceUnit: HTraspPU] Unable to build EntityManagerFactory
An http:/sscce.org/ would help.
Is the join column name 'codlinea' in both tables?
What is the DDL for both tables?
What is this mysterious unrevealed query that is such a big secret?
I use Netbeans 6.9 and Hibernate.
This is my situation:
Table: Condizioni Table: Linee
+--------+---------+--------+ +--------+----------+
|codcli |codlinea |prezzo | |codlinea|deslinea |
+--------+---------+--------+ +--------+----------+
K K K
| |
+-----------------------+
@Entity
@Table(name = "condizioni")
@NamedQuery(name = "Condizioni.findAll", query = "SELECT c FROM
Condizioni c")
public class Condizioni implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
protected CondizioniPK condizioniPK;
@Basic(optional = false)
@Column(name = "prezzo", nullable = false)
private float prezzo;
@OneToOne
@JoinColumn( name="codlinea", unique = true, nullable = false,
insertable = false, updatable = false)
private Linee linee;
@Embeddable
public class CondizioniPK implements Serializable {
@Basic(optional = false)
@Column(name = "codcli", nullable = false)
private int codcli;
@Basic(optional = false)
@Column(name = "codlinea", nullable = false)
private int codlinea;
@Entity
@Table(name = "linee")
public class Linee implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "codlinea", nullable = false)
private Integer codlinea;
@Basic(optional = false)
@Column(name = "deslinea", nullable = false, length = 30)
private String deslinea;
This code produce this error:
Exception in thread "main" javax.persistence.PersistenceException:
[PersistenceUnit: HTraspPU] Unable to build EntityManagerFactory
If I change in
@OneToOne
@JoinColumn( name="condizioniPK.codlinea", unique = true,
nullable = false, insertable = false, updatable = false)
private Linee linee;
CondizioniJpaController em = new CondizioniJpaController();
java.util.List tabellaList =
em.getEntityManager().createNamedQuery("Condizioni.findAll").getResultList();
the error is
Exception in thread "AWT-EventQueue-0"
javax.persistence.PersistenceException:
org.hibernate.exception.SQLGrammarException: could not execute query
Without @OneToOne annotation all works fine.
Help
Biagio