cancel
Showing results for 
Search instead for 
Did you mean: 

setCmrField of relation in bean to null

normann
Advisor
Advisor
0 Kudos

Hi,

I've an annoying problem:

I have 2 Tables - one with users and one with categories. There is a relation between this tables, that every user can have one category and a category can have n users (n:1).

When I delete a category, I also have to remove the category from the users table, but I dont want to delete the whole user - only his category. The dictionary field is not NOT NULL, so that I can delete the category of the user with sql-statement (update-statement).

Now the problem: I dont want to use sql-statements for many reasons. So I will do it within the bean, but when i execute

userLocal.setCmrField_relationUserCategory(null);

nothing happens. no results in database and no exception.

Does someone know this problem and may help me.

One additional question is, why can I remove a category that users have in their profile?

I thought this would not be possible due to the relation, but it happens, without an error :?

Thanks and Regards Norman

Edited by: Norman Nuernberger on Nov 3, 2008 7:08 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

d_fautini
Participant
0 Kudos

Hi,

What version os EJB are using?

normann
Advisor
Advisor
0 Kudos

Its EJB 2.0 and my entity beans have "container managed persistence".

Edited by: Norman Nuernberger on Nov 3, 2008 7:45 PM

d_fautini
Participant
0 Kudos

What about the cardinality. Shoul be: 1 User -


0..N Category

normann
Advisor
Advisor
0 Kudos

No, its 0...n Users to 1 category. So that every user is in one category, but a category can have many users.

d_fautini
Participant
0 Kudos

You need to implement User N N Category. So you need to create an intermediate table simulating the nxn relation.

If you use 1 Cat N user all the users shold have a cat.

Regards,

normann
Advisor
Advisor
0 Kudos

Yes, thats the case. And it works fine with

userLocal.setCmrField_relationUserCategory(categoryLocal);

but when a category have to be deleted, the users with this category should have no category anymore, till they choose a new one and therefor I tryed

userLocal.setCmrField_relationUserCategory(null);

and this doesn't work. Nothing happens, no result and no exception. And I want to know why. Is it wrong? How can I delete only one attribute like this:

update USERTABLE set CATEGORY = null where CATEGORY = '<deletedCategory>'

but without sql-statements?