• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JPA: incomplete SQL query

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a table:


and another table:


with the following constraints:


and

DEVICE_EQ_TYPE, DEVICE_STN_ID and DEVICE_UNIT_ID are FKs too.


"Generated" entities look like:


and:


and:
and there are some other entities which i guess (and hope) are of not much value in this context.

I need to create a Job and SubJob in the same application managed transaction.
The JPA entity managers/controller are generated.
Note: managers/controller have been modified so that they dont have to manage transactions.

Here is the code that I have written:



The error stack is:
<openjpa-1.2.1-SNAPSHOT-r422266:707222 fatal store error> org.apache.openjpa.persistence.RollbackException: The transaction has been rolled back. See the nested exceptions for details on the errors that occurred.
at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:523)
...
...
... 38 more
Caused by: <openjpa-1.2.1-SNAPSHOT-r422266:707222 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Field "entity.SubJob.pk" of "entity.SubJob@577a577a" can not be set to "entity.SubJobPK@84933dcf" value.
at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.insert(HandlerFieldStrategy.java:131)
...
...
...


The queries printed on the console are:
executing prepstmnt 885994703 INSERT INTO EM.Job (JOB_ID, SUBMITTED_BY, SUBMITTED_TS, JOB_TYPE_ID, STATUS_CD) VALUES (?, ?, ?, ?, ?) [params=(long) 19, (String) shree, (Timestamp) 2009-03-13 19:54:02.125, (long) 1, (long) 1]
[0 ms] spent
executing prepstmnt 1556241602 INSERT INTO EM.SUB_JOB (JOB_ID, JOB_TYPE_ID, STEP_ID) VALUES (?, ?, ?) [params=(long) 19, (null) null, (null) null]
[16 ms] spent


Looks like the insert of SUB_JOB query is generated in correctly/ incompletely!
Can anyone help us in rectifying the problem?

Thanks in advance
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic