java jpa remove row that as foreign key
i understand why this not leting me delete i just dont know how to get it to work
it creates a 3 table that holds foreign keys from lend and subscriber tables
how do i delete/remove one of the items from the List<lend> ???
ret=em.find(Lend.class,ret.getId());
em.remove(ret);
DELETE on table 'LEND' caused a violation of foreign key constraint
'SBSCRIBERLENDLNDID' for key (2)
@Entity public class Lend implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(cascade= CascadeType.PERSIST)
private Book lendToSub;
@Temporal(javax.persistence.TemporalType.DATE)
private Calendar timeToReturn;
@Entity public class Subscriber implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(cascade= CascadeType.PERSIST )
private List<Lend> lend;
private String fname;
private String lname;
@OneToOne(cascade= CascadeType.PERSIST)
@Embedded private Address homeaddres;
private String email;
private boolean gold;
@Transient
static String[] colms;
error i get:
xception in thread "AWT-EventQueue-0" javax.persistence.RollbackException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'LEND' caused a violation of foreign key constraint 'SBSCRIBERLENDLNDID' for key (102). The statement has been rolled back.
Error Code: -1
Call: DELETE FROM LEND WHERE (ID = ?)
bind => [102]
Query: DeleteObjectQuery(java.db.proj.Lend[ id=102 ])
i understand why this not leting me delete i just dont know how to get it to work
it creates a 3 table that holds foreign keys from lend and subscriber tables
how do i delete/remove one of the items from the List<lend> ???
ret=em.find(Lend.class,ret.getId());
em.remove(ret);
DELETE on table 'LEND' caused a violation of foreign key constraint
'SBSCRIBERLENDLNDID' for key (2)
@Entity public class Lend implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne(cascade= CascadeType.PERSIST)
private Book lendToSub;
@Temporal(javax.persistence.TemporalType.DATE)
private Calendar timeToReturn;
@Entity public class Subscriber implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToMany(cascade= CascadeType.PERSIST )
private List<Lend> lend;
private String fname;
private String lname;
@OneToOne(cascade= CascadeType.PERSIST)
@Embedded private Address homeaddres;
private String email;
private boolean gold;
@Transient
static String[] colms;
error i get:
xception in thread "AWT-EventQueue-0" javax.persistence.RollbackException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: DELETE on table 'LEND' caused a violation of foreign key constraint 'SBSCRIBERLENDLNDID' for key (102). The statement has been rolled back.
Error Code: -1
Call: DELETE FROM LEND WHERE (ID = ?)
bind => [102]
Query: DeleteObjectQuery(java.db.proj.Lend[ id=102 ])