-->
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.  [ 3 posts ] 
Author Message
 Post subject: SQL for load generated incorrectly -- Store works fine
PostPosted: Fri Sep 10, 2004 2:56 pm 
Beginner
Beginner

Joined: Wed May 12, 2004 2:52 pm
Posts: 36
Hibernate version: 2.1.3

Mapping documents:
Code:
    <class
        name="employeeclub.domain.Activity"
        table="activity"
    >

        <id
            name="id"
            type="long"
            column="id"
        >
            <generator class="net.sf.hibernate.id.TableHiLoGenerator">
                <param name="table">activity_seq</param>
                <param name="column">next_hi</param>
                <param name="max_lo">1</param>
            </generator>
        </id>

        <property
            name="name"
            type="java.lang.String"
            column="name"
            not-null="true"
            length="255"
        />
        <property
            name="description"
            type="java.lang.String"
            column="description"
            length="255"
        />


        <!-- associations -->
        <!-- bi-directional one-to-one association to ActivityTicket -->
        <one-to-one
            name="activityTicket"
            class="employeeclub.domain.ActivityTicket"
            outer-join="false"
            cascade="all"
        />
    </class>

    <subclass name="employeeclub.domain.ActivityTicket" extends="employeeclub.domain.Item" discriminator-value="ACTIVITY_TICKET">
        <!-- bi-directional many-to-one association to Activity -->
        <many-to-one
            name="activity"
            class="employeeclub.domain.Activity"
            unique="true"
        >
            <column name="detail_id" />
        </many-to-one>
    </subclass>
   
    <subclass name="employeeclub.domain.Ticket" extends="employeeclub.domain.Item"/>
   
    <class
        name="employeeclub.domain.Item"
        table="item"
        polymorphism="implicit"
        discriminator-value="not null"
    >
        <id
            name="id"
            type="long"
            column="id"
        >
            <generator class="net.sf.hibernate.id.TableHiLoGenerator">
                <param name="table">item_seq</param>
                <param name="column">next_hi</param>
                <param name="max_lo">1</param>
            </generator>
        </id>
        <discriminator
            column="type_id"
            type="java.lang.String"
        />
        <property
            name="name"
            type="java.lang.String"
            column="name"
            not-null="true"
            length="255"
        />
        <property
            name="listPrice"
            type="employeeclub.dao.hibernate.type.MoneyType"
            column="list_price"
            not-null="true"
            length="19"
        />
        <property
            name="unitCost"
            type="employeeclub.dao.hibernate.type.MoneyType"
            column="unit_cost"
            not-null="true"
            length="19"
        />
        <property
            name="description"
            type="java.lang.String"
            column="description"
            not-null="true"
            length="255"
        />

        <property
            name="quantity"
            type="int"
            column="quantity"
            not-null="true"
            length="4"
        />

    </class>


Code between sessionFactory.openSession() and session.close(): Using Spring

Full stack trace of any exception that occurs: N/A

Name and version of the database you are using: MSSQL 2k

The generated SQL (show_sql=true): Hibernate: select activity0_.id as id1_, activity0_.name as name1_, activity0_.description as descript3_1_, activityti1_.id as id0_, activityti1_.detail_id as detail_id0_, activityti1_.name as name0_, activityti1_.list_price as list_price0_, activityti1_.unit_cost as unit_cost0_, activityti1_.description as descript6_0_, activityti1_.quantity as quantity0_ from activity activity0_ left outer join item activityti1_ on activity0_.id=activityti1_.id where activity0_.id=?

Debug level Hibernate log excerpt:




The sql statement should be:

Hibernate: select activity0_.id as id1_, activity0_.name as name1_, activity0_.description as descript3_1_, activityti1_.id as id0_, activityti1_.detail_id as detail_id0_, activityti1_.name as name0_, activityti1_.list_price as list_price0_, activityti1_.unit_cost as unit_cost0_, activityti1_.description as descript6_0_, activityti1_.quantity as quantity0_ from activity activity0_ left outer join item activityti1_ on activity0_.id=activityti1_.detail_id where activity0_.id=?

This is specified in the many-to-one mapping for activityTicket. Saving these two objects works fine.

How do I get hibernate to user detail_id instead of id when loading these two objects?

Regards,

Joshua


Top
 Profile  
 
 Post subject: Hibernate version is 2.1.4
PostPosted: Fri Sep 10, 2004 2:57 pm 
Beginner
Beginner

Joined: Wed May 12, 2004 2:52 pm
Posts: 36
The hibernate version is 2.1.4 not 2.1.3


Top
 Profile  
 
 Post subject: Your help would be appreciated
PostPosted: Sat Sep 11, 2004 1:56 pm 
Beginner
Beginner

Joined: Wed May 12, 2004 2:52 pm
Posts: 36
I am stuck here. If anyone could help me out, I would greatly appreciate it.

Thanks,

Joshua


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