Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » em.remove throws exception: identifier is too long(em.remove throws exception: identifier is too long)
em.remove throws exception: identifier is too long [message #632812] Thu, 14 October 2010 06:53 Go to next message
Deepak  is currently offline Deepak
Messages: 2
Registered: October 2010
Junior Member
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 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 995
Registered: July 2009
Senior Member
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
Previous Topic:JPQL query does not locate the constructor correctly
Next Topic:Using a fetch group with find
Goto Forum:
  


Current Time: Thu Apr 24 01:25:53 EDT 2014

Powered by FUDForum. Page generated in 0.26565 seconds