I created a class:
package com.paslists.prm.entity;
import javax.persistence.*;
import com.haulmont.cuba.core.entity.BaseLongIdEntity;
import com.haulmont.chile.core.annotations.NamePattern;
@NamePattern("%s|comments")
@AttributeOverrides({
@AttributeOverride(name="id", column=@Column(name="ID"))
})
@Table(name = "GWCOMMENTS")
@Entity(name = "prm$GWComment")
public class GWComment extends BaseLongIdEntity {
private static final long serialVersionUID = 1130005077378204782L;
@Column(name = "COMMENTS", length = 256)
protected String comments;
@MapsId
@OneToOne(fetch = FetchType.LAZY, mappedBy = "comments")
@JoinColumn(name="id")
protected Gateway customer;
public void setCustomer(Gateway customer) {
this.customer = customer;
}
public Gateway getCustomer() {
return customer;
}
public void setComments(String comments) {
this.comments = comments;
}
public String getComments() {
return comments;
}
}
I then went into my customer record and set up a one-to-one mapping with the comments record, like this:
@OneToOne(fetch = FetchType.LAZY, cascade=CascadeType.ALL)
@PrimaryKeyJoinColumn
protected GWComment comments;
This seems to get past the build, but CUBA still wants to update the database with a script to create a foreign key. How do I stop that from happening?
And, strangely, the SQL fails - but when I extract if from the app.log and run it by hand the SQL works fine. The only edits I make are to fill in the “?” parameters. The link to comments actually looks correct, too. :-/
Query: ReadAllQuery(referenceClass=Gateway sql="SELECT * FROM (SELECT a.*, ROWNUM rnum FROM
(SELECT t1.ID AS a1, t1.BATCHNUM AS a2, t1.BIRTHDAY AS a3, t1.CITY AS a4, t1.COMPANY AS a5, t1.CPURCH AS a6,
t1.DEL AS a7, t1.EMAIL AS a8, t1.FIRST AS a9, t1.FPURCH AS a10, t1.GNDEL AS a11, t1.HADEL AS a12, t1.HDEL
AS a13, t1.HOTLINE AS a14, t1.JOBTITLE AS a15, t1.LAST AS a16, t1.LPURCH AS a17, t1.MI AS a18,
t1.NAME AS a19, t1.NCOADATE AS a20, t1.NHPDEL AS a21, t1.NHZDEL AS a22, t1.NOBDEL AS a23,
t1.NUMPURCH AS a24, t1.ORIGDATE AS a25, t1.PERMDEL AS a26, t1.PHONE AS a27, t1.PRIMADDR AS a28,
t1.RTYPE AS a29, t1.SECADDR AS a30, t1.SEXCODE AS a31, t1.STATE AS a32, t1.ZIP AS a33, t1.ZIP4 AS a34,
t0.ID AS a35, t0.COMMENTS AS a36
FROM GATEWAY t1 LEFT OUTER JOIN GWCOMMENTS t0 ON (t0.ID = t1.ID), gwprods t3, gwtrans t2
WHERE (((t3.CORPCODE = ?) OR (? = ?)) AND ((t2.GATEWAY_ID = t1.ID) AND (t3.PROD_ID = t2.GWPRODS_PROD_ID))) ORDER BY t1.ZIP, t1.LAST) a
WHERE ROWNUM <= ?)
WHERE rnum > ?")
FetchGroup(){birthday, city, hotline, batchnum, del, zip4, ncoadate, rtype, hdel, hadel, nobdel, permdel, company, gndel, state, id, m
i, sexcode, email, origdate, zip, comments => {class java.lang.Object=FetchGroup(comments){comments, id}}, fpurch, jobtitle, last, sec
addr, lpurch, nhzdel, transactions => {class java.lang.Object=FetchGroup(transactions){amount, quantity, gwprodsProdId => {class java.
lang.Object=FetchGroup(gwprodsProdId){prodCode, active, id, prodDesc, corpcode}}, transnum, batchnum, purchDate, credCard, source, prm
ordnum, refdate, refamt, paymethod, retcheck, ccexpDate, id, gatewayId => {class java.lang.Object=FetchGroup(gatewayId){birthday, city
, hotline, batchnum, del, zip4, ncoadate, rtype, hdel, hadel, nobdel, permdel, company, gndel, state, id, mi, sexcode, email, origdate
, zip, fpurch, jobtitle, last, secaddr, lpurch, nhzdel, primaddr, phone, nhpdel, numpurch, name, first, cpurch}}, key, shipdate}}, primaddr, phone, nhpdel, numpurch, name, first, cpurch}
---
java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist