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