-->
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: composite-element query yields object with null parent
PostPosted: Wed Jun 30, 2004 1:36 am 
Newbie

Joined: Wed Jun 30, 2004 1:10 am
Posts: 2
Using a composite-element with a parent tag and running this query:

Code:
select elements(grp.frames)
from com.trailmagic.image.ImageGroup grp
join grp.frames frame
where grp = :album
AND frame.image.id = :imageId


I get back an object that has the parent (ImageGroup) set to null (even just running the query in Hibern8ide, modified only to specify real values for the named parameters). Is the mapping wrong? Is the query wrong? I've been going nuts trying to figure this one out, and I seem to keep running into problems with this composite-element. Can anyone help? The composite-element is being used to add link attributes to a many-to-many table, BTW.

Here's the relevant mapping:

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

<hibernate-mapping
  package="com.trailmagic.image">
 
  <class
    name="ImageGroup"
    table="image_groups">

    <id
      name="id"
      type="long"
      column="group_id"
      unsaved-value="0"
      access="property">
      <generator class="sequence">
        <param name="sequence">id_sequence</param>
      </generator>
    </id>

    <many-to-one name="supergroup" column="supergroup_id"
      not-null="true"/>

    <set name="subgroups" inverse="true" cascade="all">
      <key column="supergroup_id"/>
      <one-to-many class="ImageGroup"/>
    </set>
   

    <property name="name">
      <column name="name" sql-type="varchar(100)" not-null="true"
        unique-key="image_groups_name_owner"/>
    </property>

    <property name="displayName">
      <column name="display_name" sql-type="varchar(1024)"
      not-null="true"/>
    </property>

    <property name="type">
      <column name="type" sql-type="varchar(100)" not-null="true"/>
    </property>

    <property name="description">
      <column name="description" sql-type="varchar(2048)"/>
    </property>

    <many-to-one name="owner"
      class="com.trailmagic.user.User"
      cascade="none">
      <column name="owner_id" not-null="true"
        unique-key="image_groups_name_owner"/>
    </many-to-one>

   
    <list
      name="frames"
      table="image_frames"
      cascade="all-delete-orphan"
      lazy="false"
      inverse="true">
      <key>
        <column name="group_id" unique-key="frames_group_position"/>
      </key>
      <index>
        <column name="position" unique-key="frames_group_position"
          not-null="true"/>
      </index>

    <composite-element class="ImageFrame">
        <parent name="imageGroup"/>
        <property name="caption">
          <column name="caption" sql-type="varchar(4000)"/>
        </property>
        <many-to-one name="image" class="Image" cascade="none">
          <column name="image_id" not-null="true"/>
        </many-to-one>
      </composite-element>
    </list>
  </class>
<!-- This never worked
  <class name="ImageFrame">
    <property name="imageGroup"/>
    <property name="position"/>
    <property name="caption"/>
    <property name="image"/>
  </class>
    -->
</hibernate-mapping>


Thanks!

P.S. This is on Hibernate 2.1.4 against a Postgres 7.4.2 database.


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.