-->
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.  [ 6 posts ] 
Author Message
 Post subject: HQL Translation Error?
PostPosted: Mon Oct 06, 2008 9:34 pm 
Newbie

Joined: Sun Sep 28, 2008 6:10 pm
Posts: 6
Hi, I was wondering if anyone can help me solve this problem:

This is my HQL:

SELECT COUNT(obj.id) FROM MyObject AS obj WHERE obj.otherObject.id like '%example%'

This is what gets generated from hibernate via debug statement:

select count(myobject0_.id) as col_0_0_ from MYOBJECT myobject0_ where myobject0_.id like '%example%'

It looks like hibernate disregarded the otherObject. The otherObject is an object attribute within MyObject class, which contains an id field.

Is this an error or am I mapping it wrong? I'm mapping otherObject with the JoinColumn attribute. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 4:32 am 
Newbie

Joined: Fri Aug 29, 2008 9:07 am
Posts: 16
Location: edinburgh/zielona gora
Is the property 'otherObject' correctly initialised when you initialise MyObject object?
could you provide your mapping file and both classes please?

cheers
radek


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 1:17 pm 
Newbie

Joined: Sun Sep 28, 2008 6:10 pm
Posts: 6
Thanks for replying. I'm using JPA. Here's my mapping:
-----------------------------------------------------------------
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="OBJ_TYPE")
public abstract class MyObject {

@Id
private long id;

@JoinColumn(nullable=false)
private OtherObject otherObject;

...
//getters and setters
...
}
---------------------------------------------------------------------
@Entity
public class OtherObject {

@Id
@Column(length=24)
private String id;

...
//getters and setters
...
}

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 1:19 pm 
Newbie

Joined: Sun Sep 28, 2008 6:10 pm
Posts: 6
Don't know why the messages was re-posted for 5 times.


Last edited by zeert2002 on Tue Oct 07, 2008 8:22 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 1:23 pm 
Newbie

Joined: Sun Sep 28, 2008 6:10 pm
Posts: 6
Don't know why the messages was re-posted for 5 times.


Last edited by zeert2002 on Tue Oct 07, 2008 8:22 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 1:23 pm 
Newbie

Joined: Sun Sep 28, 2008 6:10 pm
Posts: 6
Don't know why the messages was re-posted for 5 times.


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