-->
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.  [ 5 posts ] 
Author Message
 Post subject: basic question about session.delete()
PostPosted: Thu Oct 30, 2003 4:15 pm 
Regular
Regular

Joined: Tue Oct 14, 2003 11:11 pm
Posts: 62
Location: Brasil/Curitiba
Hi,

It's a basic question, but can anyone answer me?

if I want to delete a row, do I need to call session.load() before session.delete()?

and why ?

thank you

_________________
Ricardo Lecheta


Top
 Profile  
 
 Post subject: I think
PostPosted: Thu Oct 30, 2003 5:13 pm 
Newbie

Joined: Mon Oct 20, 2003 12:18 pm
Posts: 12
Location: Mexico
Well Im also new in Hibernate, but like I understand when you want to delete an object you need to have this object, so you can get the object with load sentence or with finder method (you need to extract specific object from list).
I'm not sure if exist other form for access an object but if you know something maybe you can tell me this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 30, 2003 6:04 pm 
Regular
Regular

Joined: Tue Oct 14, 2003 11:11 pm
Posts: 62
Location: Brasil/Curitiba
ok,

but you can create a new instance of the object without load the object from database...

Code:
PersonVO p = new PersonVO();
p.setId(new Integer(1));
session.delete(p);


but sometimes this not work, and why not ?

thanks

_________________
Ricardo Lecheta


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2003 4:08 pm 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
From the javadoc:

Remove a persistent instance from the datastore. The argument may be an instance associated with the receiving Session or a transient instance with an identifier associated with existing persistent state.

So I guess it doesn't have to be an instance loaded with Session.load().

One question that someone else can perhaps answer is What happens if said instance has been loaded but then you call delete with a non-persistent instance? If this is illegal, could this be the source of your problems?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 31, 2003 7:48 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It has to be an instance that contains the current database state. Otherwise Hibernate doesn't know what associated objects to delete/nullify.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.