-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: problem deleting with only id field.
PostPosted: Mon Jun 06, 2005 10:24 am 
Newbie

Joined: Thu May 27, 2004 9:14 am
Posts: 11
hibernate 3.0.5

I'm having problems deleting entities. I have a dao layer in which I pass in the ID only and not the class. This is done mainly so that I don't have to take a round trip to the db if I receive just an ID from the client tier.

So I don't want to have to call the dao layer to find an object by id then delete it for a simple delete operation (2 round trips to the db).

The error returned is:

not-null property references a null or transient value: com.verisign.caf.refapp.domainobject.Channel.channelName; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.verisign.caf.refapp.domainobject.Channel.channelName

I understand that the Channel.channelName is a not-null field but why should that matter if I'm essentially just trying to excercise a delete which references only the ID field and not the channelName field in particular?

Also I've tried this with and without a sql-delete in the mapping file.

Thanks,

Cory


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 11:32 am 
Newbie

Joined: Thu May 27, 2004 9:14 am
Posts: 11
I found several posts relating to this but I think the best answser to avoid the round trip is to use the load method to return a proxiable object. I've not tested but hope that this will avoid the round trip.

It's odd though that a delete operation would be concerned with anything other than the ID field that was used in the delete SQL.........


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 11:47 am 
Newbie

Joined: Thu May 27, 2004 9:14 am
Posts: 11
Should the deletion of an object with only an id while having no concern for other (not-null=true) fields be a feature request?

Is there a reason that this behavior is a feature?

Thanks,

Cory


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 06, 2005 7:58 pm 
Newbie

Joined: Wed May 25, 2005 11:32 am
Posts: 14
I have similar problem. What I did is using query object and call query.excuteUpdate(queryString);

your queryString is something like
" delete from Foo foo where foo.id = 1 "


This works when no relation in Foo object.
I run into the problem when Foo have set.

For Example:
I have Asset and AssetGroup Objects:
<class name="Asset" table="ASSET">
<id name="id" type="int" column="ASSET_SID">
<generator class="native"/>
</id>
<property name=...
<set name="groups" table="ASSET_GROUP_MAP" inverse="true" lazy="true" cascade="delete">
<key column="ASSET_SID" />
<many-to-many class="AssetGroup" column="ASSETGROUP_SID"/>
</set>
</class>

<class name="AssetGroup" table="ASSETGROUP">
<id name="id" type="int" column="ASSETGROUP_SID">
<generator class="native"/>
</id>
<property name=...
<set name="assets" table="ASSET_GROUP_MAP" lazy="true" cascade="delete">
<key column="ASSETGROUP_SID" />
<many-to-many class="Asset" column="ASSET_SID"/>
</set>
</class>

When I try to do
query.excuteUpdate("delete from AssetGroup where id=..");

I got Integrity constraint violation. Can anyone tell me what is the correct way to cascade delete relation MAP in this case?


Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.