-->
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.  [ 2 posts ] 
Author Message
 Post subject: JPQL returns null when association field has a null value
PostPosted: Wed Feb 28, 2007 1:32 am 
Newbie

Joined: Wed Feb 28, 2007 12:58 am
Posts: 2
Hi all,

I'm using hibernate 3.2 with JPA and I have the following relationship between the object
Code:

@Entity
@Table(name = "RC_JOB")
@SequenceGenerator(name = "NEWOPS_SEQ", sequenceName = "SQ_JOB_CNTR")
public class JobBo extends AbstractBo {


    /**
     * The related customer
     */
    @ManyToOne
    @JoinColumn(name = "CUSTOMER_ID")
    private CustomerBo customer;

.....
}


@Entity
@Table(name = "MD_CUSTOMER")
@SequenceGenerator(name = "NEWOPS_SEQ", sequenceName = "SQ_CUSTOMER_CNTR")
public class CustomerBo extends AbstractBo {

    /**
     * CustomerNumber
     */
    @Column(name = "CUSTOMERNUMBER", length = 25)
    private String customerNumber;
.......
}


Now I have the following query to be executed on Job and its associated-field

Code:
SELECT new com.dpwn.newops.shared.dto.DemoForMarkus(job.id,job.customer.customerNumber) FROM JobBo job where job.id=123


In the database, I have a job record with id 123, but this record doesn't have a associated customer ( job.customer is null)

The problem is that when I execute the query (query.getResultList()), I always get a empty array list but my expectation is that query should return a list containing DemoForMarkus object where attribute job.customer.customerNumber will be null.

Is there anything, I'm missing in my query to get my expected result?

Thanks,
Ravi


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 28, 2007 12:23 pm 
Newbie

Joined: Wed Feb 28, 2007 12:58 am
Posts: 2
Got this fixed, it was a problem in my Query

Code:
SELECT new com.dpwn.newops.shared.dto.DemoForMarkus(job.id,job.customer.customerNumber,job.consignmentNote.consignmentNoteNumber ) FROM JobBo job LEFT OUTER JOIN job.customer where job.id= 123


Thanks


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