users@glassfish.java.net

entitymanager.merge is not deleting the entity mapping element..

From: <glassfish_at_javadesktop.org>
Date: Wed, 20 Aug 2008 14:17:29 PDT

Hi,

I am trying out toplink JPA over glassfish using ejb3. I have two beans as follows

AccountEntity {

@OneToMany(cascade = CascadeType.ALL)
        @JoinTable(name = "account_property_mapping", joinColumns = { @JoinColumn(name = "account_id") }, inverseJoinColumns = { @JoinColumn(name = "property_id") })
        private Set<PropertyEntity> properties;
}

PropertyEntity {

... bunch of fields
}

both beans have corresponding tables and the mapping table is "account_property_mapping"..

And in my session bean i am converting my DTOs to the above entities

the code for updating looks like

updateAccount(AccountDto dto)
{

AccountEntity account = new AccountEntity();
account.setId(dto.getId());

Set<PropertyEntity> properties
for(PropertyDto property : dto.getProperties())
{
 PropertyEntity prop = new PropertyEntity();
prop.setId(property.getId())
....
set other fields
}

account.setProperties(properties);

entityManager.merge(account)..




Now when i first create the account with 3 properties the entitymanager persisted properly but when i try to update the account by removing one property, the JPA is removing the mapping from the table "account_property_mapping" but not deleteing the property from the property table??

Am i missing something here?
[Message sent by forum member 'eligetiv' (eligetiv)]

http://forums.java.net/jive/thread.jspa?messageID=294464