-->
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: Cross queries between Hibernate and JPA/Hibernate: possible?
PostPosted: Thu Jun 07, 2007 4:16 am 
Newbie

Joined: Thu Jun 07, 2007 4:01 am
Posts: 2
Hibernate version: 3.2.0 GA

Name and version of the database you are using: Oracle9


The background: application uses JPA with Hibernate underneath it for persistence. Now we dropped in JBPM with its pure Hibernate persistence. The goal is to query a tasklist (TaskInstance is a JBPM entity) and join our JPA entities inside that query, something like this:

Code:
<query name="theQuery">
   <![CDATA[
     select ti
     from the.package.TaskInstance as ti,
        the.domain.Customer as cust
     where ti.isSuspended != true
       and ti.isOpen = true
       and ti.entityId = cust.id
       and cust.customerNumber = '700061'
   ]]>
</query>


the.package.TaskInstance is an entity managed by Hibernate, described in mapping files, all that kind of stuff. This is basically an extension of the JBPM TaskInstance.
Now the.domain.Customer is our own home grown domain entity persisted with JPA (Hibernate underneath). All its metadata is decribed in annotations, like this:

Code:
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames="customerNumber"))
public class Customer extends BaseEntity implements Identifiable {
...


So what we do is we want to have both Hibernate and JPA entities in the same query. However as SessionFactoryImpl.checkNamedQueries() processes the query above it ends up with an exception complaining that 'the.domain.Customer is not mapped'. Customer class is there in the class path so in theory the metadata is available in the runtime. The question is: is it possible to make that metadata somehow available to the session factory parsing such a heterogeneous query? Is there an alternative way to make a cross query without duplicating Customer metadata (the one described in annotations) in the mapping files?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 08, 2007 3:27 am 
Newbie

Joined: Thu Jun 07, 2007 4:01 am
Posts: 2
Found a solution -- drop *.hbm.xml mappings as <mapping-file/> inside persistence.xml and Hibernate JPA implementation will happily pick them up. After that a query involving entities from both Hibernate and JPA/Hibernate domain could be used from the Entity Manager.


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.