-->
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: Efficient Manipulation of component/value based collections
PostPosted: Sat May 03, 2008 8:41 pm 
Newbie

Joined: Sat May 03, 2008 8:03 pm
Posts: 1
Location: USA
Class

Code:
    [Serializable()]
   public class CalendarEvent   
   {      
      public virtual DateTime DateCreated {get; set;}
      public virtual string Title    {get; set;}
      public virtual Location Location {get; set;}
      public virtual string RRule {get; set;}
      public virtual IList<DateTime> Occurrences {get; set;}
      // Snip.....
   }
   



Mapping

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
   namespace="SocialDance.Core.Domain.Events" assembly="SocialDance.Core">

   <class name="CalendarEvent" table="calendar_events">               
      <id name="Id" type="Int32" unsaved-value="0">
         <column name="id" sql-type="int" not-null="true" unique="true"/>
         <generator class="native" />
      </id>
      <property name="Title" type="String">
         <column name="title" length="128" sql-type="varchar" not-null="true"/>
      </property>
      <many-to-one name="Location" type="Location">
         <column name="location_id" sql-type="int" not-null="true"/>
      </many-to-one>
      <property name="RRule" type="String">
         <column name="rrule" length="128" sql-type="varchar" not-null="true"/>
      </property>
      <property name="DateCreated" type="DateTime">
         <column name="date_added" sql-type="datetime" not-null="true"/>
      </property>
      <bag name="Occurrences" table="sd_CalendarEventOccurrences" order-by="start_date ASC">
         <key column="event_id"/>
            <element column="start_date" type="DateTime"/>
         </bag>
      </class>
</hibernate-mapping>



The occurrences collection is populated initially based on an ICal RRule specification, but can be manipulated externally. The question is how to efficiently
manipulate the list without having to load all the elements. In other words, i want to be able to add or remove an occurrence without having to load the
parent event and manipulate the Occurrences property (triggering a full load).
The only workaround to this, which is not as semantically nice, is to create a class representing the join (e.g. CalendarEventOccurrence) and
work with those instead.

jbland


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.