Hi,
I am using a lookuptable from invoice to customer via customer-id. So when I have an entity of the invoice-table and try to read a field of the related customer, I am getting the following error:
IllegalStateException: Cannot get unfetched attribute [kunde] from detached object com.pd.abf.entity.AuftragKopf-3004 [detached].
Here is a part of the invoice-entity:
–snip –
@NamePattern("%s|buchnungsNummer")
@Table(name = “ABF_AUFTRAG_KOPF”)
@Entity(name = “abf$AuftragKopf”)
public class AuftragKopf extends BaseLongIdEntity implements Versioned, Updatable, Creatable, HasUuid {
private static final long serialVersionUID = 4516857111684197168L;
@NotNull
@Column(name = "KOPF_ID", nullable = false, unique = true)
protected Long kopfId;
@Temporal(TemporalType.DATE)
@Column(name = "RECHNUNGS_DATUM")
protected Date rechnungsDatum;
@Column(name = "BUCHUNGS_NUMMER", nullable = false, unique = true, length = 20)
protected String buchnungsNummer;
@Column(name = "RECHNUNGS_NUMMER", unique = true)
protected Long rechnungsNummer;
@Column(name = "BEMERKUNG", length = 2000)
protected String bemerkung;
**@NotNull**
** @ManyToOne(fetch = FetchType.LAZY, optional = false)**
** @JoinColumn(name = “KUNDE_ID”)**
** protected Adresse kunde;**
@Temporal(TemporalType.DATE)
@Column(name = "DATUM", nullable = false)
protected Date datum;
@Composition
@OneToMany(mappedBy = "aufftragsKopf")
protected List<AuftragsPosition> position;
@Column(name = "VORNAME", length = 80)
protected String vorname;
@Column(name = "NAME1", nullable = false, length = 80)
protected String name1;
@Column(name = "NAME2", length = 80)
protected String name2;
@Column(name = "NAME3", length = 80)
protected String name3;
@Column(name = "STRASSE", length = 80)
protected String strasse;
–snip–
What is the way, get the lookup-entity fetched (here it is “Adresse”).
Thanks very much.