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.  [ 7 posts ] 
Author Message
 Post subject: Wrong mapping with generics
PostPosted: Wed Aug 23, 2006 5:47 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 6:05 am
Posts: 42
Hello,

I am using Hibernate version: 1.2.0 Alpha 1 and while mapping a generic collection I am getting the following Error:
Code:
{"Could not find a getter for property 'NHibernateTest.Revisions, NHibernateTest' in class 'NHibernateTest.Stage'"}


Here my files:

Stage.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="NHibernateTest.Stage, NHibernateTest" table="STAGE">
    <id name="Id" type="System.Guid" column="ID">
      <generator class ="assigned" />
    </id>
    <property name="Caption" column="CAPTION" />
    <set name ="NHibernateTest.Revisions, NHibernateTest">
      <key column ="ID_STAGE" />
      <many-to-many class="NHibernateTest.Revision, NHibernateTest" column ="ID_REVISON" />
    </set>
  </class>
</hibernate-mapping>

Revision.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="NHibernateTest.Revision, NHibernateTest" table="REVISION">
    <id name="Id" type="System.Guid" column="ID">
      <generator class="assigned" />
    </id>
    <property name="savedObjectType" column="SAVED_OBJECT_TYPE" />
    <property name="savedObjectId" column="SAVED_OBJECT_ID" />
  </class>
 
</hibernate-mapping>


Stage.cs
Code:
...
namespace NHibernateTest {
    public sealed class Stage {
   
        private static IList<Revision> revisions = new List<Revision>();
        ...

        public static IList<Revision> Revisions
        {
            get { return revisions; }
            set { revisions = value; }
        }

        ...
        static Stage()
        {
             ...
        }
        ...
    }
}


Can anyone help?

Thank you!

eg


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 5:54 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The name attribute in <set> should be the name of the property (probably just "Revisions"), not the class it points to.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 6:44 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 6:05 am
Posts: 42
sergey wrote:
The name attribute in <set> should be the name of the property (probably just "Revisions"), not the class it points to.


First thank you, second sorry that wasn't the error. Though it was an error, but not the only one ;)
I changed the XML to
Code:
    <set name ="Revisions">
      <key column ="ID_STAGE" />
      <many-to-many class="NHibernateTest.Revision, NHibernateTest" column ="ID_REVISON" />
    </set>

which should be correct (see Stage.cs). But the error still remains.
Can it has something to do with the static or sealed attribute?

thank you


eg


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 7:58 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
What error remains? Post the new error message please.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 8:47 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 6:05 am
Posts: 42
sergey wrote:
What error remains? Post the new error message please.

Still the same I post in the starting post. Here is a more detailed version.

Exception:
Code:
System.TypeInitializationException wurde nicht behandelt.
  Message="Der Typeninitialisierer für NHibernateTest.Stage hat eine Ausnahme verursacht."
  Source="NHibernateTest"
  TypeName="NHibernateTest.Stage"
  StackTrace:
       bei NHibernateTest.Stage.get_Instance()
       bei NHibernateTest.StageManager..ctor() in C:\Dokumente und Einstellungen\admin\Eigene Dateien\Eigene Projekte\Spielwiese\NHibernateTest\classes\StageManager.cs:Zeile 23.
       bei NHibernateTest.Form1..ctor() in C:\Dokumente und Einstellungen\admin\Eigene Dateien\Eigene Projekte\Spielwiese\NHibernateTest\Form1.cs:Zeile 25.
       bei NHibernateTest.Form1.Main() in C:\Dokumente und Einstellungen\admin\Eigene Dateien\Eigene Projekte\Spielwiese\NHibernateTest\Form1.cs:Zeile 137.
       bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       bei System.Threading.ThreadHelper.ThreadStart()

Inner Exception
Code:
{"Error reading resource: NHibernateTest.Stage.hbm.xml"}

and
Code:
{"Could not find a getter for property 'Revisions' in class 'NHibernateTest.Stage'"}


Stacktrace
Code:
"   bei NHibernateTest.Stage.get_Instance()\r\n   bei NHibernateTest.StageManager..ctor() in C:\\Dokumente und Einstellungen\\admin\\Eigene Dateien\\Eigene Projekte\\Spielwiese\\NHibernateTest\\classes\\StageManager.cs:Zeile 23.\r\n   bei NHibernateTest.Form1..ctor() in C:\\Dokumente und Einstellungen\\admin\\Eigene Dateien\\Eigene Projekte\\Spielwiese\\NHibernateTest\\Form1.cs:Zeile 25.\r\n   bei NHibernateTest.Form1.Main() in C:\\Dokumente und Einstellungen\\admin\\Eigene Dateien\\Eigene Projekte\\Spielwiese\\NHibernateTest\\Form1.cs:Zeile 137.\r\n   bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)\r\n   bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n   bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   bei System.Threading.ThreadHelper.ThreadStart()"


Thank you

eg


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 23, 2006 10:23 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Ahh right, I overlooked it. NHibernate cannot work with static properties so all your properties have to be non-static.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 11:34 am 
Beginner
Beginner

Joined: Fri Dec 23, 2005 6:05 am
Posts: 42
sergey wrote:
Ahh right, I overlooked it. NHibernate cannot work with static properties so all your properties have to be non-static.


Thank you, that was the problem.


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