Hi guys,
I'm trying to create a little project around EJB / JPA linked to a Mysql
database. I got two tables FctData and RefKpiDataQuery linked by a foreign
key.
FctData :
public class FctData implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "DATA_ID")
private Long dataId;
...
@JoinColumn(name = "DATA_QUERY_REF", referencedColumnName =
"KPI_DATA_QUERY_ID")
@ManyToOne(cascade = CascadeType.ALL)
private RefKpiDataQuery dataQueryRef;
----------------
RefKpiDataQuery :
public class RefKpiDataQuery implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "KPI_DATA_QUERY_ID")
private Long kpiDataQueryId;
...
@OneToMany(cascade = CascadeType.ALL, mappedBy = "dataQueryRef")
private Set<FctData> fctDataSet;
I got a client which is just trying to insert a FctData in the database
RefKpiDataQuery refKpiDataQuery = new RefKpiDataQuery();
refKpiDataQuery.setKpiDataQueryId((long) 2);
FctData fctData = new FctData();
fctData.setDataQueryRef(refKpiDataQuery);
fctDataFacade.insert(fctData);
The Facade is a kind of DAO. This thing is working great with object which
don't have a FK.
Here is the error that i get in my log :
Field 'DATA_QUERY_REF' doesn't have a default value {prepstmnt 7235700
INSERT INTO FCT_DATA(DATA_DATE, DATA_TIME, DATA_VALIDITY, DATA_VALUE,
ISACTIVE, UPDATE_OWNER, UPDATE_TS) VALUES (?, ?, ?, ?, ?, ?, ?)
As we can see in my insert it never talks about the dataQuery. Someone can
explain me what did i miss ? I can't find my mistake.
Thanks for your time. Cheers
--
View this message in context: http://openjpa.208410.n2.nabble.com/Insert-not-using-foreign-key-tp7582616.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
|