em.remove throws exception: identifier is too long [message #632812] |
Thu, 14 October 2010 06:53  |
Eclipse User |
|
|
|
I have a header(user_header_test) and a detail(user_detail_test) table, where the header table has one-to-many relationship with the detail table. when i want to find and delete the header using EntityManager, it fails. I see that in the generated SQL, the table name has header table name appended with detail table name(i.e DELETE FROM USER_HEADER_TEST_USER_DETAIL_TEST WHERE ..). What I may be doing wrong?. Thanks.
I am using EclipseLink 2.1.1
code snippet:
@Entity
@Table(name = "user_header_test")
@IdClass(UserHeaderPK.class)
public class UserHeader implements Serializable {
@Id
@Column(name = "APP_ID", length = 1000)
private String appId;
@Id
@Column(name = "USER_ID", length = 1000)
private String userId;
@OneToMany(mappedBy = "userHeader", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private Collection<UserDetail> members = new ArrayList<UserDetail>();
.......
}
@Entity
@Table(name = "user_detail_test")
public class UserDetail implements Serializable {
@Id
@Column(name = "ID")
private int id;
@Column(name = "USER_ADDRESS", length = 1000)
private String address;
@ManyToOne()
@JoinColumns( { @JoinColumn(name = "APP_ID",
referencedColumnName = "APP_ID"),
@JoinColumn(name = "USER_ID",
referencedColumnName = "USER_ID") })
private UserHeader userHeader;
...
}
public class JPATest {
private static EntityManagerFactory emf;
private static EntityManager em;
...
UserHeader userHeader = em.find(...);
em.remove(userHeader);
// The above fails with the exception
/*
Internal Exception: java.sql.SQLSyntaxErrorException: ORA-00972: identifier is too long
Error Code: 972
Call: DELETE FROM USER_HEADER_TEST_USER_DETAIL_TEST WHERE ((APP_ID = ?) AND (USER_ID = ?))
bind => [app,12345]
Query: DataModifyQuery(sql="DELETE FROM USER_HEADER_TEST_USER_DETAIL_TEST WHERE ((APP_ID = ?) AND (USER_ID = ?))")
*/
}
|
|
|
Re: em.remove throws exception: identifier is too long [message #632840 is a reply to message #632812] |
Thu, 14 October 2010 08:51  |
Eclipse User |
|
|
|
Hello,
The error indicates that EclipseLink believes there is a ManyToMany or unidirectional OneToMany on the UserHeader class to UserDetail, and it is using a default relation table. I would recommend you set the EclipseLink log level to finest, and check the logs for when the UserHeader class is being processed. Could you be using an orm.xml file, or have annotations on the methods in the UserHeader class? Annotations on the methods might cause the field level annotations to be ignored.
Best Regards,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.03381 seconds