-->
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.  [ 2 posts ] 
Author Message
 Post subject: Sharing a table between a <bag> and a <class>
PostPosted: Mon Apr 12, 2004 3:09 pm 
Beginner
Beginner

Joined: Tue Oct 28, 2003 12:09 pm
Posts: 46
I'm trying to help a some friedns out and they've got something I think is BAD but wanted to bounce it off the list to make sure.

Basically, the have a java object mapped to a table "EmailSendEvent". It has many attributes but they are using two of them in a separate mapping of a persistent collection to back a <bag> mapping.

The two mappings follow at the end of this message.

They also reference the EmailSendEvent by id from other many-to-one mappings.

It seems like a bad idea to both have hibernate control the mapping for the <bag> and to have business logic depend on those objects and referencing them by id.

It seems to work, but we're tracking down bugs now that are a bit slippery.

Anyway, here are the mappings. Is this bad or am I just being overly nervous about it?

-mp


Code:
  <class name="org.groundspring.emailnow.event.EmailSendEvent"
          table="EventEmailSend">

      <id name="id" type="long" column="id">
              <generator class="native"/>
      </id>

      <property name="tstamp" column="tstamp" type="timestamp"
                not-null="true"/>

      <many-to-one name="job"
                   column="jobId"
                   class="org.groundspring.emailnow.Job"
                   not-null="true"/>

      <many-to-one name="campaign"
                   column="campaignId"
                   class="org.groundspring.emailnow.model.Campaign"
                   not-null="false"/>

      <many-to-one name="member"
                   column="memberId"
                   class="org.groundspring.emailnow.model.Member"
                   not-null="true"/>

      <property name="hash" column="hash" type="long" not-null="true"/>

   </class>


Code:
     <bag name="sentMembers" table="EventEmailSend" lazy="true">
         <key column="jobId" />
         <many-to-many class="org.groundspring.emailnow.model.Member"
                       column="memberId"/>
      </bag>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 11:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Map the bag with inverse="true", and it should be harmless.


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