Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C9DB0E9A2 for ; Wed, 23 Jan 2013 14:12:05 +0000 (UTC) Received: (qmail 50736 invoked by uid 500); 23 Jan 2013 14:12:05 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 50463 invoked by uid 500); 23 Jan 2013 14:12:05 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 50437 invoked by uid 99); 23 Jan 2013 14:12:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2013 14:12:04 +0000 X-ASF-Spam-Status: No, hits=2.8 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of maxtorzito@gmail.com designates 74.125.82.169 as permitted sender) Received: from [74.125.82.169] (HELO mail-we0-f169.google.com) (74.125.82.169) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jan 2013 14:11:57 +0000 Received: by mail-we0-f169.google.com with SMTP id t11so2338537wey.0 for ; Wed, 23 Jan 2013 06:11:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=3DqR4rdFiCAjJ27YFJd0lrXzpnR+r2csIhcZWDpMdfo=; b=abMEZ8VL2ZZHoCTnxYQKLrljMSUC0yafmtIntxXuXfdvTxrHyGDQt26kxzhqTnffDF nNt2aOwwo7j6i5rJ4pEHWUXovSLAM95NXKo+J1FaefV6IpRg/5N12V29WZ84pYc18aCJ mAvgHkLzfGEiHJU8HKIA2PMfVeeGNAqM/7LNJ/jTIp+iixevSzbTgJav4h5IkXVlfXg3 BdZnSoXywtKXJKkXPPFf7bEkxVuO6Ehe6qk+MM+01h68hb4Y5gNcoIG2mTqVcP+YpEBH 0xM+ZB1vy0E4tSX9R8inPJah7LzJK72iGk6OxcMFrezSQLWkyrHOcXdPEIEZqd91WHlG 1swA== MIME-Version: 1.0 X-Received: by 10.194.179.34 with SMTP id dd2mr2950357wjc.1.1358950297300; Wed, 23 Jan 2013 06:11:37 -0800 (PST) Received: by 10.194.136.10 with HTTP; Wed, 23 Jan 2013 06:11:37 -0800 (PST) Received: by 10.194.136.10 with HTTP; Wed, 23 Jan 2013 06:11:37 -0800 (PST) In-Reply-To: <1358949167883-7582616.post@n2.nabble.com> References: <1358949167883-7582616.post@n2.nabble.com> Date: Wed, 23 Jan 2013 08:11:37 -0600 Message-ID: Subject: Re: Insert not using foreign key From: =?ISO-8859-1?Q?Jos=E9_Luis_Cetina?= To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=089e0141a002bced7304d3f54538 X-Virus-Checked: Checked by ClamAV on apache.org --089e0141a002bced7304d3f54538 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Check your table where the field DATA_QUERY_REF is. This field have a "wrong" date value. Some date before 1970 or just like 0000-00-00 could be the problem. JPA sometimes do selects before inserts. El 23/01/2013 07:53, "J=E9r=F4me" escribi=F3: > 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 foreig= n > key. > > FctData : > > public class FctData implements Serializable { > > @Id > @GeneratedValue(strategy =3D GenerationType.IDENTITY) > @Column(name =3D "DATA_ID") > private Long dataId; > > ... > > @JoinColumn(name =3D "DATA_QUERY_REF", referencedColumnName =3D > "KPI_DATA_QUERY_ID") > @ManyToOne(cascade =3D CascadeType.ALL) > private RefKpiDataQuery dataQueryRef; > > ---------------- > > RefKpiDataQuery : > > public class RefKpiDataQuery implements Serializable { > > @Id > @GeneratedValue(strategy =3D GenerationType.IDENTITY) > @Basic(optional =3D false) > @Column(name =3D "KPI_DATA_QUERY_ID") > private Long kpiDataQueryId; > > ... > > @OneToMany(cascade =3D CascadeType.ALL, mappedBy =3D "dataQueryRef") > private Set fctDataSet; > > I got a client which is just trying to insert a FctData in the database > > RefKpiDataQuery refKpiDataQuery =3D new RefKpiDataQuery(); > refKpiDataQuery.setKpiDataQueryId((long) 2); > > FctData fctData =3D new FctData(); > fctData.setDataQueryRef(refKpiDataQuery); > > fctDataFacade.insert(fctData); > > > The Facade is a kind of DAO. This thing is working great with object whic= h > 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 ca= n > 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-tp758261= 6.html > Sent from the OpenJPA Users mailing list archive at Nabble.com. > --089e0141a002bced7304d3f54538--