-->
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: Criteria Join Without hbm Mapping--Possible?
PostPosted: Thu Aug 07, 2008 10:02 am 
Beginner
Beginner

Joined: Tue Sep 13, 2005 4:54 pm
Posts: 34
Here's my question: I have an object--
Code:
Recipe2
--whose Primary Key is
Code:
recipeId
.

I have another object--
Code:
Recipe2DeploymentStatus
--that has a foreign key to the
Code:
Recipe2
object's
Code:
recipeId
.

Code:
Recipe2
has a 1:1 relationship with
Code:
Recipe2DeploymentStatus


The problem is this: I cannot define a mapping within
Code:
Recipe2.hbm.xml
to
Code:
Recipe2DeploymentStatus
because the TABLE backing
Code:
Recipe2DeploymentStatus
can NOT exist in any of the other schemas except the single admin schema where deployment status is used. So, I have a relationship that cannot be defined in
Code:
Recipe2
.


So, I guess my question boils down to this: is it possible to define a Criteria query that will fetch the associated table rows WITHOUT defining a mapping?

thank you,
Ty
-----------------------------------------------------------------------------
Hibernate version: Hibernate3

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.myco.recipe.domain">

   <class name="Recipe2" table="recipe2" dynamic-update="true" mutable="true">

        <cache usage="read-write" />
        <id name="id" column="recipe_id" type="long" unsaved-value="0" >
            <generator class="sequence">
                <param name="sequence">recipe2_id_seq</param>
            </generator>
        </id>

        <version name="version" column="version" />

        <many-to-one name="recipeType" column="recipe_type_code" class="RecipeType" />

        <property name="title" column="title" type="string" not-null="true"/>
        <property name="issueDescription" column="issue_desc" type="string"/>
        <property name="introduction" column="introduction" type="string"/>
        <property name="otherSourceText" column="other_source_text" type="string"/>
        <property name="otherSectionText" column="other_section_text" type="string"/>

        <list name="ingredientGroups" inverse="true" table="INGREDIENT_GROUP" cascade="all-delete-orphan" >
            <key>
                <column name="RECIPE_ID" not-null="true" />
            </key>
            <list-index column="SEQUENCE_NUM" />
            <one-to-many class="com.myco.recipe.domain.IngredientGroup" />
        </list>

        <list name="preparationGroups" inverse="true" table="PREPARATION_GROUP" cascade="all-delete-orphan" >
            <key>
                <column name="RECIPE_ID" not-null="true" />
            </key>
            <list-index column="SEQUENCE_NUM" />
            <one-to-many class="com.myco.recipe.domain.PreparationGroup" />
        </list>

        <list name="nutrientGroups" inverse="true" table="NUTRIENT_GROUP" cascade="all-delete-orphan" >
            <key>
                <column name="RECIPE_ID" not-null="true" />
            </key>
            <list-index column="SEQUENCE_NUM" />
            <one-to-many class="com.myco.recipe.domain.NutrientGroup" />
        </list>

        <property name="prepTime" column="prep_time" type="string"/>
        <property name="activeTime" column="active_time" type="string"/>
        <property name="totalTime" column="total_time" type="string"/>
        <property name="originalTime" column="orig_time" type="string"/>
        <property name="author" column="author" type="string"/>
        <property name="publication" column="publication" type="string"/>
        <property name="publisher" column="publisher" type="string"/>
        <property name="edition" column="edition" type="string"/>
        <property name="copyright" column="copyright" type="string"/>
        <property name="copyrightCopyDisplay" column="copyright_copy_display" type="string"/>
        <property name="restaurant" column="restaurant" type="string"/>
        <property name="editorialNote" column="editorial_note" type="string"/>
        <property name="originalNutritionDescription" column="orig_nutr_desc" type="string"/>
        <property name="preheatTemp" column="preheat_temp" type="string"/>
        <property name="cookingTemp" column="cooking_temp" type="string"/>
        <property name="preparationNotesTitle" column="preparation_notes_title" type="string"/>
        <property name="chefNotes" column="chef_notes" type="string"/>
        <property name="searchKeywords" column="search_keywords" type="string"/>

        <bag name="servingSizes" inverse="true" order-by="SEQUENCE_NUM" cascade="all-delete-orphan">
            <key column="recipe_id" />
            <one-to-many class="RecipeServingSize"  />
        </bag>

        <property name="creationDate" column="creation_date" type="timestamp" not-null="true"/>
        <property name="modifiedDate" column="modified_date" type="timestamp" not-null="true"/>
        <property name="liveDate" column="live_date" type="timestamp"/>
        <property name="expirationDate" column="expiration_date" type="timestamp"/>
        <property name="searchableDate" column="searchable_date" type="timestamp"/>

        <one-to-one name="recipeStats" class="RecipeStats" cascade="all"/>

        <property name="reviewWithCommentsCount" type="int" lazy="true">
            <formula>(SELECT count(*)
                      FROM recipe_review a
                      where a.recipe_id = recipe_id
                      and a.review_text is not null)
            </formula>
        </property>

        <property name="isActive" column="is_active" type="yes_no" not-null="true" />
        <property name="isSearchable" column="is_searchable" type="yes_no" not-null="true" />
        <property name="isDeleted" column="is_deleted" type="yes_no" not-null="true" />
        <property name="isFood" column="is_food" type="yes_no" not-null="true" />
        <property name="isDrink" column="is_drink" type="yes_no" not-null="true" />
        <property name="isBuzzBoxable" column="is_buzz_boxable" type="yes_no" not-null="true" />
        <property name="modifiedBy" column="modified_by" type="string"/>
        <property name="imageCredit" column="img_credit" type="string"/>
                                                                                      
        <set name="reviews" order-by="MODIFIED_DATE desc" table="recipe_review" lazy="true" inverse="true" cascade="all-delete-orphan" >
               <cache usage="read-write"/>
               <key column="recipe_id"/>
               <one-to-many class="Review"/>
        </set>

        <set name="attributes" table="recipe_attribute2" cascade="delete">
               <cache usage="read-write"/>
               <key column="recipe_id"/>
               <many-to-many class="com.myco.attribute.domain.Attribute" column="attribute_id" />
        </set>

        <set name="wines" table="wine_pairing2" lazy="true" cascade="delete" >
               <cache usage="read-write"/>
               <key column="recipe_id"/>
               <many-to-many class="com.myco.wine.domain.Wine" column="wine_id"/>
        </set>

        <set name="slides" table="Slide" lazy="true" cascade="all-delete-orphan">
               <cache usage="read-write"/>
               <key column="recipe_id"/>
               <one-to-many class="com.myco.slideshow.domain.Slide"/>
        </set>

        <set name="media" table="recipe_media2" lazy="true" cascade="delete">
            <cache usage="read-write"/>
            <key column="recipe_id"/>
            <many-to-many class="com.myco.media.domain.Media" column="media_id"/>
        </set>

        <bag name="recipeLinks" table="recipe_link2" inverse="true" lazy="true" cascade="all-delete-orphan" order-by="sequence_num">
               <cache usage="read-write"/>
               <key column="recipe_id"/>
               <one-to-many class="com.myco.recipe.domain.RecipeLink2"/>
        </bag>

        <many-to-one name="sourceSection" class="com.myco.sourcesection.domain.SourceSection2" column="SOURCE_SECTION_ID" cascade="all" />

    </class>

</hibernate-mapping>

-------------------------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.myco.recipe.domain">

    <class name="Recipe2DeploymentStatus" table="RECIPE2_DEPLOYMENT_STATUS" dynamic-update="true" mutable="true">

        <cache usage="read-write" />
        <id name="recipeId" column="RECIPE_ID" type="long">
            <generator class="assigned"/>
        </id>

        <property name="dateSavedInAdmin"             column="DATE_SAVED_IN_ADMIN"         type="timestamp" lazy="false"    />
        <property name="dateDeployedInPreview"         column="DATE_DEPLOYED_PREVIEW"         type="timestamp" lazy="false"    />
        <property name="dateDeployedInStaging"         column="DATE_DEPLOYED_STAGING"         type="timestamp" lazy="false"    />
        <property name="dateDeployedInProduction"     column="DATE_DEPLOYED_PRODUCTION"     type="timestamp" lazy="false"    />

    </class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
unremarkable

Full stack trace of any exception that occurs:
NA

Name and version of the database you are using:
Oracle 10

The generated SQL (show_sql=true):
NA yet

Debug level Hibernate log excerpt:
NA yet

Problems with Session and transaction handling?
NA yet
[/code]


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.