• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Strange error after em.persist

 
max afinogenov
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone.
I have an entity "message" with fields emp_id, local_user_id, message_date, message_header, message_id.
I want to save it to a table "message" with corresponding columns.
But after em.persist(message) I got this exception:

org.apache.openjpa.lib.jdbc.ReportingSQLException: ORA-00904: "LOCAL_USER_LOCAL_USER_ID": недопустимый идентификатор
{prepstmnt 42 INSERT INTO Message (emp_id, local_user_id, message_date, message_header, emp_emp_id, local_user_local_user_id) VALUES (?, ?, ?, ?, ?, ?) [params=(int) 8, (int) 0, (null) null, (String) , , 7, 9, 6., (null) null, (null) null]} [code=904, state=42000]

Entity "message" has 2 many-to-one relations - local_user and emp. Why JPA tries to insert something to non-existing columns (emp_emp_id, local_user_local_user_id)?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your entities which has the annotations.
 
max afinogenov
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am trying ta save this entity only.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Entity "message" has 2 many-to-one relations - local_user and emp.


Assuming that your Message entity has foreign key "emp_id" for Emp and "local_user_id" for Local_user, your annotations should look like:



If you omit the JoinColumn annotation, the EJB 3.0 server would choose a default column name for you, which in this case i guess is turning out to be emp_emp_id and local_user_local_user_id
 
max afinogenov
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


After this I get compilation error - cannot resolve symbol
What else can I try?
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you added the following import statement

 
max afinogenov
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, of course. Error is in name="emp_id" and name="local_user_id"
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if that doesnt work, can you post the compilation error that you are seeing?
 
max afinogenov
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I develop using IDEA, so

These 2 symbols are "emp_id" and "local_user_id"
Mb there is another way??
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what the cause of this compilation errors is, but i do see that you have 2 private member variables:

private int emp_id;
private int local_user_id;


Can you remove these and the corresponding getter/setter and see if it works. Let us know, if it doesn't.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic