-->
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.  [ 3 posts ] 
Author Message
 Post subject: problem in a delete where clause on a OneToOne relationship
PostPosted: Wed Jan 02, 2008 10:26 am 
Beginner
Beginner

Joined: Fri Apr 20, 2007 10:48 am
Posts: 49
Location: France
3.3

The generated SQL (show_sql=true):
delete from WorkExecution where plan_id=? and (id is null) and state=?

this sql is generated for the following query:

Code:
Query query = em.createQuery( "DELETE FROM " + WorkExecution.class.getSimpleName() + " e WHERE e.entriesPlan.id = :id AND e.invoiceWorkDetail=null AND e.state = :temp " );

where e.invoiceWorkDetail is as follows:

WorkExecution.java
Code:
   @OneToOne(mappedBy = "workExecution", fetch = FetchType.EAGER, cascade = {
         CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH
   })
   public InvoiceWorkDetail getInvoiceWorkDetail() {
      return invoiceWorkDetail;
   }


So as you see, the relationship I'm trying to write in the where clause is to say: the workExecution doesn't have any child in the table InvoiceWorkDetail. (As I'd do in java)

Unfortunately it is translated to a non sens (id is null)

Anyone has an idea? any suggestion is very welcome

Regards,
Zied

_________________
Regards,
Zied Hamdi


Top
 Profile  
 
 Post subject: error?
PostPosted: Thu Jan 03, 2008 4:10 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Zhamdi,

I don't like this

Quote:
AND e.invoiceWorkDetail=null


Shouldn't an "is null' be there?

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 04, 2008 5:27 am 
Beginner
Beginner

Joined: Fri Apr 20, 2007 10:48 am
Posts: 49
Location: France
Hi gonzao,

I gave up because I'm too busy: I resolved it in java.

I don't think it's the problem: it is translated to "id is null". The problem is that hibernate doesn't do an inner select but translates simple to "id is null" notice it's e.invoiceWorkDetail that must be null: that means in sql: there is no child in the child table.

Thanks for your suggestion.

_________________
Regards,
Zied Hamdi


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