permaculture playing cards*
The moose likes Object Relational Mapping and the fly likes Strange error after em.persist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Strange error after em.persist" Watch "Strange error after em.persist" New topic
Author

Strange error after em.persist

max afinogenov
Greenhorn

Joined: Jun 10, 2007
Posts: 9
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

Joined: Jul 20, 2005
Posts: 9962
    
163

Please post your entities which has the annotations.


[My Blog] [JavaRanch Journal]
max afinogenov
Greenhorn

Joined: Jun 10, 2007
Posts: 9

I am trying ta save this entity only.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

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

Joined: Jun 10, 2007
Posts: 9


After this I get compilation error - cannot resolve symbol
What else can I try?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

Have you added the following import statement

max afinogenov
Greenhorn

Joined: Jun 10, 2007
Posts: 9
Yes, of course. Error is in name="emp_id" and name="local_user_id"
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

And if that doesnt work, can you post the compilation error that you are seeing?
max afinogenov
Greenhorn

Joined: Jun 10, 2007
Posts: 9
I develop using IDEA, so

These 2 symbols are "emp_id" and "local_user_id"
Mb there is another way??
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9962
    
163

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.
 
 
subject: Strange error after em.persist
 
Similar Threads
Mapping
Applet loads times on init!
Is Zirf Slavic?
For Michael Matola
USB+Windows(needed libruary)