-->
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.  [ 7 posts ] 
Author Message
 Post subject: Table per concrete class inheritance mapping query
PostPosted: Mon Dec 22, 2003 1:08 am 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
I'm using Hibernate 2.1.1.

I've been reading Chapter 16 - Inheritance Mappings, and it says something I don't understand.
I'm primarily interested in the section that deals with using a table-per-concrete-class strategy.

This section seems to say that if I have two normally mapped classes (unrelated) and have them both implement the same (unmapped) interface, then they are now part of a table-per-concrete-class mapping?

It then goes on to say (last paragraph of 16.1):
Quote:
If we execute a query against the Payment interface - for example, from Payment - Hibernate automatically returns instances [of the concrete classes]

I'm trying to simplify this situation down (no mappings from other entities to the interface, no properties on the interface), but it's not working for me.
I get an exception:
Code:
net.sf.hibernate.QueryException: unexpected token: as [from ElvasContact as contact]


Am I mis-understanding the documentation? Or am I simplifying the example down too much (maybe I need to have a property declared on the interface)?

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 1:30 am 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Actually, turns out it works.

You just can't use an unqualified classname; for normal classes you can just use the classname (as long as you don't have duplicate classnames and have Hibernate configured appropriately), but for this kind of un-mapped superclass, you seem to need to use the fully qualified classname.

Might be worth noting in the doco (or is it already documented somewhere else, in which case sorry for the noise)?

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 2:22 am 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Also, I get:
Code:
net.sf.hibernate.MappingException: No persister for: nrm.clas.domain.elvas.contact.ElvasContact

when I try to use the interface class in a Criteria query.

Is it not possible to use these unmapped superclasses in Criteria queries, or am I doing something wrong (again)?

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2004 6:59 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
<bump>

So how about it?
Is it not possible to query with these "unmapped superclass" type objects using the criteria API?

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2004 7:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Criteria API is a subset of HQL, add an issue to JIRA please.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 04, 2004 7:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
If I read the source correclty, the criteria API in the moment just works for mapped classes, this might be worth a JIRA entry.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 06, 2004 1:20 am 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
Created HB-608: http://opensource.atlassian.com/project ... key=HB-608

There's a dodgy patch attached that kind of does the job in the same way as the HQL code does (two queries, unioned in java land).

_________________
Cheers,
Shorn.


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