Hi All,
I am very new to
EJB 3.0 and JPA and while implementation i have got one issue.
In the application i have 3 table say A,B & C. B has a FK relationship with PK of A. So functionality is when i update a record in A, a new record with some more details has to be entered in B. So while enter the data in B, i have to check a user entered value in C. To achieve this i am creating a PK Object of the C to get the uniqueness.
Everything is working fine but when i am running the
test cases A record is updating in A, a new Record is inserting in B & a New record is also inserted in C.
So in C i dont want to insert the record but it is going and inserting a new record.
I guess somewhere i am wrong to use cascadeType, please help me if anybody has came such scenario.
Code -
--------
POJO for Table A
----------------------
@OneToOne(cascade = CascadeType.REMOVE, mappedBy = "aId")
private B bColumn;
POJO for Table B
------------------------
@JoinColumns( {
@JoinColumn(name = "C_ID", referencedColumnName = "C_ID", nullable = false),
@JoinColumn(name = "B_VALUE", referencedColumnName = "VALUE", nullable = false, insertable = false, updatable = false) })
@ManyToOne
private EnumCTable enumCTable;
@JoinColumn(name = "A_ID", referencedColumnName = "A_ID", nullable = false)
@OneToOne(optional = false)
private A aId;
Thanks in Advance,
Shishir