java - delete persisted object in one to one relation -


i'm using openjpa mapping layer , have 2 models : user :

@entity @table(name = "users") public class user {     @id     @generatedvalue(strategy = generationtype.sequence,generator = "user_id_gen")     @sequencegenerator(name = "user_id_gen", sequencename = "manage.users_id", allocationsize=1)     @column(name = "id", nullable = false)     private int _id;      @onetoone (cascade=cascadetype.all, fetch = fetchtype.eager)     @joincolumn(name="fk_image_id", insertable=true, updatable=true, nullable = true)     private image _image; 

and image

@entity @table(name = "images") public class image {     @id     @generatedvalue(strategy = generationtype.sequence,generator = "images_id_gen")     @sequencegenerator(name = "images_id_gen", sequencename = "manage.image_id", allocationsize=1)     @column(name = "id")     private int _id; 

it's unidirectional 1 one relation.

the problem want remove image without removing user , when remove user remove image associated him.

right when delete image delete user !!

found solution. set image field null , save user object , delete image.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -