-->
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.  [ 4 posts ] 
Author Message
 Post subject: collection dereference issue with 1.2 beta 2
PostPosted: Sun Nov 26, 2006 4:36 pm 
Newbie

Joined: Sun Nov 26, 2006 4:08 pm
Posts: 10
Location: Seattle, WA
If I create an ActivitySet with one Activity (the base class, not EvaluationActivity) in it, Save it (flush/clear/close/reopen session), then query for the ActivitySet and Flush, A 'You may not dereference an collection with cascade="all-delete-orphan"' exception is thrown.

I've debugged into it a bit and it appears that NHibernate is attempting to flush a QuestionEntity collection. There should never have been a QuestionEntity collection loaded though because there are no EvaluationActivity's in the db, and there are certainly none on the ActivitySet I just created.

I do not ever dereference a QuestionEntity collection, as it is never referenced. This has only started to occur while attempting to upgrade to NHib 1.2.

Any ideas?

Thanks,

Aaron

Hibernate version:

1.2 beta 2

Mapping documents:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Company.Server" namespace="Company.Server.Entities" default-lazy="false">
<class name="ActivitySetEntity" table="co_activity_set" discriminator-value="">
    <cache usage="read-write" />
    <id name="Id" column="Id" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>

    <property name="Name" column="Name" type="String" />
    <bag name="Activities" lazy="true" table="co_activity_set_membership" cascade="save-update" outer-join="true"
      inverse="false"
    >
      <key column="ActivitySetId" />
      <many-to-many column="ActivityId" class="Company.Server.Entities.ActivityEntity" />
    </bag>
  </class>

  <class name="ActivityEntity" table="co_activity" discriminator-value="0">
    <cache usage="read-write" />
    <id name="Id" column="Id" type="Int32" unsaved-value="0">
      <generator class="native" />
    </id>

     <discriminator column="ActivityType" type="String" />
   
    <property name="Name" column="Name" type="String" />
    <property name="Mnemonic" column="Mnemonic" type="Char" />
    <property name="IsRequired" column="IsRequired" type="Boolean" />
      <subclass name="Company.Server.Entities.SkillSectionEntity" discriminator-value="8">
     </subclass>
      <subclass name="Company.Server.Entities.ScoredActivityEntity" discriminator-value="1">
        <subclass name="Company.Server.Entities.EvaluationActivityEntity" discriminator-value="3">
          <bag name="Questions" lazy="true" table="" cascade="all-delete-orphan" outer-join="true"
            inverse="false"
          >
            <key column="EvaluationActivityId" />
            <one-to-many class="Company.Server.Entities.QuestionEntity" />
          </bag>
            <subclass name="Company.Server.Entities.QuizActivityEntity" discriminator-value="5">
           </subclass>
            <subclass name="Company.Server.Entities.TestActivityEntity" discriminator-value="4">
           </subclass>
       </subclass>
     </subclass>
      <subclass name="Company.Server.Entities.SkillSetActivityEntity" discriminator-value="2">
     </subclass>
      <subclass name="Company.Server.Entities.PlacementActivityEntity" discriminator-value="6">
      <bag name="Skills" lazy="true" table="co_placement_activity_skill" cascade="none" outer-join="true"
        inverse="false"
      >
        <key column="PlacementActivityId" />
        <many-to-many column="SkillId" class="Company.Server.Entities.SkillEntity" />
      </bag>
     </subclass>
  </class>
 
</hibernate-mapping>


Full stack trace of any exception that occurs:

Code:
NHibernate.HibernateException: You may not dereference an collection with cascade="all-delete-orphan"
   at NHibernate.Impl.SessionImpl.UpdateUnreachableCollection(IPersistentCollection coll) in c:\net\nhibernate\nhibernat
e\src\NHibernate\Impl\SessionImpl.cs:line 3957
   at NHibernate.Impl.SessionImpl.FlushCollections() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:
line 3802
   at NHibernate.Impl.SessionImpl.FlushEverything() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs:l
ine 3090
   at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet querySpaces) in c:\net\nhibernate\nhibernate\src\NHibernate\I
mpl\SessionImpl.cs:line 2273
   at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results) in c:\net\nhibernate\nhibernate\src\NHibern
ate\Impl\SessionImpl.cs:line 5071
   at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria) in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\Sessio
nImpl.cs:line 5027
   at NHibernate.Impl.CriteriaImpl.List() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\CriteriaImpl.cs:line 302
   at NHibernate.Impl.CriteriaImpl.UniqueResult() in c:\net\nhibernate\nhibernate\src\NHibernate\Impl\CriteriaImpl.cs:li
ne 406
   at Company.Server.Data.Access.HibernateDao`2.QueryByUniqueCriteria(ICriterion expression) in C:\Home\Source\Company
\projects\Company.Data\Access\HibernateDao.cs:line 114
   at Company.Server.Data.Access.UserDao.QueryByUsername(String username) in C:\Home\Source\Company\projects\Company.
Data\Access\UserDao.cs:line 30
   at Company.Tools.DataImporter.TestUserAdder.Go() in C:\Home\Source\Company\projects\Company.Tools.DataImporter\Add
ers.cs:line 938
   at Company.Tools.DataImporter.AbstractDatabaseAccessor.Go(IDaoFactory daoFactory, ISession session, DataImporterOpti
ons options) in C:\Home\Source\Company\projects\Company.Tools.DataImporter\IDatabaseAccessor.cs:line 43
   at Company.Tools.DataImporter.Program.Main(String[] args) in C:\Home\Source\Company\projects\Company.Tools.DataImp
orter\Program.cs:line 40


Name and version of the database you are using:

Sql Server 2005

The generated SQL (show_sql=true):
Code:
SELECT this_.Id as Id22_4_, this_.Name as Name22_4_, activities2_.ActivitySetId as Activity1___6_,
       activityen3_.Id as ActivityId6_, activityen3_.Id as Id45_0_, activityen3_.Name as Name45_0_,
       activityen3_.Mnemonic as Mnemonic45_0_, activityen3_.IsRequired as IsRequired45_0_,
       activityen3_.ActivityType as Activity2_0_, questions4_.EvaluationActivityId as Evaluati9___7_,
       questions4_.Id as Id7_, questions4_.Id as Id14_1_,
       questions4_.InstructionText as Instruct2_14_1_, questions4_.InstructionImageFile as Instruct3_14_1_,
       questions4_.InstructionSoundFile as Instruct4_14_1_, questions4_.PromptText as PromptText14_1_,
       questions4_.PromptImageFile as PromptIm6_14_1_, questions4_.PromptSoundFile as PromptSo7_14_1_,
       questions4_.SkillId as SkillId14_1_, options5_.QuestionId as QuestionId__8_,
       options5_.Id as Id8_, options5_.Id as Id49_2_, options5_.ImageFile as ImageFile49_2_,
       options5_.Text as Text49_2_, options5_.AudioFile as AudioFile49_2_,
       options5_.IsCorrect as IsCorrect49_2_, skills6_.PlacementActivityId as Placemen1___9_,
       skillentit7_.Id as SkillId9_, skillentit7_.Id as Id4_3_, skillentit7_.Name as Name4_3_,
       skillentit7_.SkillType as SkillType3_
FROM co_activity_set this_ left outer join co_activity_set_membership activities2_ on this_.Id=activities2_.ActivitySetId
left outer join co_activity activityen3_ on activities2_.ActivityId = activityen3_.Id
left outer join co_question questions4_ on activityen3_.Id=questions4_.EvaluationActivityId
left outer join co_option options5_ on questions4_.Id=options5_.QuestionId
left outer join co_placement_activity_skill skills6_ on activityen3_.Id=skills6_.PlacementActivityId
left outer join co_skill skillentit7_ on skills6_.SkillId=skillentit7_.Id
WHERE this_.Name = @p0; @p0 = 'Unit Activities'



Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 28, 2006 4:11 pm 
Newbie

Joined: Sun Nov 26, 2006 4:08 pm
Posts: 10
Location: Seattle, WA
Has anybody seen this before? This really smells like a bug...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 1:44 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Report this to JIRA with a test case and I will have a look.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 3:53 am 
Newbie

Joined: Sun Nov 26, 2006 4:08 pm
Posts: 10
Location: Seattle, WA
Done.

http://jira.nhibernate.org/browse/NH-826

Apparently it's only a problem when querying with Criteria. HQL Queries seem unaffected.


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