-->
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.  [ 5 posts ] 
Author Message
 Post subject: Different results
PostPosted: Fri Oct 10, 2003 4:57 pm 
Newbie

Joined: Fri Oct 03, 2003 11:58 am
Posts: 14
I have the folowing set defined in an entity called Host:
================================================
<set name="serviceStatuses" lazy="false">
<key column="host_name"/>
<one-to-many class="com.contego.arx.domain.Service"/>
</set>
================================================

When I let Hibernate automatically populate this Set it returns 1 result (incorrect number).

When I perform a find I get 2 results (correct number) using the following code:
================================================
getSession()
.createCriteria( Service.class )
.add( Expression.eq( "hostname", h.getHostname() ) )
.list()
================================================

Any ideas why this would return different results?

Thanks,

Chris


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2003 5:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Need to see the whole mapping for the class defining:
<set name="serviceStatuses" lazy="false">
<key column="host_name"/>
<one-to-many class="com.contego.arx.domain.Service"/>
</set>

And please use the [ code ] tags...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2003 5:46 pm 
Newbie

Joined: Fri Oct 03, 2003 11:58 am
Posts: 14
Sorry.

Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
    <class name="com.contego.arx.domain.Host" table="hoststatus">
        <id name="hostname" type="java.lang.String" column="host_name">
            <generator class="assigned"/>
        </id>
        <property name="hostStatus" type="java.lang.String" column="host_status"/>
        <property name="lastUpdate" type="java.util.Date" column="last_update"/>
        <property name="lastCheck" type="java.util.Date" column="last_check"/>
        <property name="lastStateChange" type="java.util.Date" column="last_state_change"/>
        <property name="problemAcknowledged" type="java.lang.Boolean" column="problem_acknowledged"/>
        <property name="timeUp" type="java.lang.Long" column="time_up"/>
        <property name="timeDown" type="java.lang.Long" column="time_down"/>
        <property name="timeUnreachable" type="java.lang.Long" column="time_unreachable"/>
        <property name="lastNotification" type="java.util.Date" column="last_notification"/>
        <property name="currentNotification" type="java.lang.Integer" column="current_notification"/>
        <property name="notificationsEnabled" type="java.lang.Boolean" column="notifications_enabled"/>
        <property name="eventHandlerEnabled" type="java.lang.Boolean" column="event_handler_enabled"/>
        <property name="checksEnabled" type="java.lang.Boolean" column="checks_enabled"/>
        <property name="pluginOutput" type="java.lang.String" column="plugin_output"/>
        <property name="scheduledDowntimeDepth" type="java.lang.Integer" column="scheduled_downtime_depth"/>
        <property name="flapDetectionEnabled" type="java.lang.Boolean" column="flap_detection_enabled"/>
        <property name="isFlapping" type="java.lang.Boolean" column="is_flapping"/>
        <property name="percentStateChange" type="java.lang.Double" column="percent_state_change"/>
        <property name="failurePredictionEnabled" type="java.lang.Boolean" column="failure_prediction_enabled"/>
        <property name="processPerformanceData" type="java.lang.Boolean" column="process_performance_data"/>
        <set name="serviceStatuses" lazy="false">
            <key column="host_name"/>
            <one-to-many class="com.contego.arx.domain.Service"/>
        </set>

    </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 10, 2003 9:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Everything looks right. I would suggest taking a look at how you implement hashCode() and equals(). You are using a Set for mapping that collection; problems with either of those overrides could cause an issue like that (especially hashCode()).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 13, 2003 9:42 am 
Newbie

Joined: Fri Oct 03, 2003 11:58 am
Posts: 14
I am not overriding either of those methods.

It just seems really weird.

I suppose I will be forced to checkout the code and see if I can find the problem.


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