-->
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.  [ 1 post ] 
Author Message
 Post subject: key-many-to-one problem
PostPosted: Mon Jan 30, 2006 10:55 am 
Newbie

Joined: Mon Jan 30, 2006 8:04 am
Posts: 1
Hi,

I have a problem in hibernate's object consultation.


The problem is following:

I have a class named ProductClient and another named Client.
The atribute primary key of the Client class composes the composition key of the ProductClient class.
I need consultation every ProductClient of a Client.
For this, I used the following OQL sentence:

Code:
StringBuilder _hql = new StringBuilder();
_hql.Append("select pc ");
_hql.Append("  from ProductClient pc ");
_hql.Append(" where pc.Client.Id = " + _client.Id.ToString());


The method is return me every ProductClient of Table ProductClient and I wanted every ProductClient of a Client. When I try to read the value of the Client's Key, return me the following exception:

Code:
Object reference not set to an instance of an object.



When I remove the following restriction:

Code:
_hql.Append(" where pc.Cliente.Id = " + _cliente.Id.ToString());


the Client object's values return me without problems.

I also already tried the following sentence.

Code:
StringBuilder _hql = new StringBuilder();
_hql.Append("select pc ");
_hql.Append("  from ProductClient pc ");
_hql.Append(" inner join pc.Client c ");
_hql.Append(" where c.Id = " + _client.Id.ToString());


but It don't worked too.



Somebody could help me?

Thanks!
Luiz César Cherri


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

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.