-->
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: MappingException in Eclipse
PostPosted: Wed May 10, 2006 4:32 am 
Newbie

Joined: Wed May 10, 2006 3:54 am
Posts: 2
Hello there,

I found a strange MappingException in my class

I load all the Users in my Database and all the "Roles" they can play. The Roles contains a Set of Rights assigned to each Role. This set should be loaded lazily.

After the User logged in I discard the information about all the other Users and want to initialize the User and the Role he choses and also the Rights this Role has in the database.

The Session that is used to all the Users and Roles before the login is closed as soon as its job is finished. After the login I open a new Session to fetch all the data that was missed during that first run.

Now the Error as described below happens right after the call to Session.merge() occurs.

I use eclipse 3.2, with hibernate imported as a "plugin from existing jars".
The HibernateUtil is in a different plugi than my login code, Eclipse-RegisterBuddy: org.hibernate
is set onall relevant plugins.

Everythings works fine with lazy="false" for the Set, but that is obviously not what I want.

I can see no obvious Error and did not find anything helpful in any of the forums, so thank you in advance for any hints.

RĂ¼diger

Hibernate version:
3.2.0 cr2

Mapping documents:
Code:
<hibernate-mapping>
   <class name="de.fischeradt.users.types.Rolle">
      <id name="id" column="Rolle_id" type="long">
         <generator class="native" />
      </id>
      <natural-id>
         <property name="name" type="string" />
      </natural-id>
      <set name="RolleRecht" table="RolleRecht">
         <key column="rolle_id"  />
         <element type="de.fischeradt.users.types.RolleRechtType">
            <column name="recht" />
            <column name="grant" />
         </element>
      </set>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
            Session session = HibernateUtil.getSession();
            Transaction transaction = session.beginTransaction();
            try {
                    Set<?> rolleRecht = nextRole.getRolleRecht();
                    if (!Hibernate.isInitialized(rolleRecht)) {
                        session.merge(rolleRecht);
                        Hibernate.initialize(rolleRecht);
                    }
            } finally {
                if (transaction != null) {
                    transaction.commit();
                }
            }


Full stack trace of any exception that occurs:
Code:
org.hibernate.MappingException: Unknown entity: org.hibernate.collection.PersistentSet
   at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:547)
   at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1331)
   at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
   at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:487)
   at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:90)
   at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:51)
   at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:679)
   at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:663)
   at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:667)
   at de.fischeradt.users.UserRepository.setCurrentUserAndRole(UserRepository.java:186)
   at de.fischeradt.users.UserLoginDialog.okPressed(UserLoginDialog.java:366)
   at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:500)
   at org.eclipse.jface.dialogs.Dialog$3.widgetSelected(Dialog.java:652)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:925)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3346)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
   at org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
   at org.eclipse.jface.window.Window.open(Window.java:796)
   at de.fischeradt.connect.UserConnector.loginUser(UserConnector.java:32)
   at de.fischeradt.Application.doLogin(Application.java:42)
   at de.fischeradt.Application.run(Application.java:21)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
   at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
   at org.eclipse.core.launcher.Main.run(Main.java:977)
   at org.eclipse.core.launcher.Main.main(Main.java:952)


Name and version of the database you are using:
HSQLDB 1.8.0


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 1:24 am 
Newbie

Joined: Wed May 10, 2006 3:54 am
Posts: 2
OKay, found the Error myself. Don't know where I got the wrong code, of course it must be

Code:
                    Set<?> rolleRecht = nextRole.getRolleRecht();
                    if (!Hibernate.isInitialized(rolleRecht)) {
                        session.update(nextRole);
                        Hibernate.initialize(rolleRecht);
                    }


I just don't know why the Exception that was thrown was
Quote:
org.hibernate.MappingException: Unknown entity: org.hibernate.collection.PersistentSet


Cheers,
RĂ¼diger


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.